Buongiorno Eleuterio,
nel precedente post non sono riuscito a mandare il codice quindi ho allegato l'immagine, ora ho capito la procedura e lo rimando:
Public Sub CaricaAcconti(codiclie As Integer, NSH As Integer)
Dim VERSAMENTI As acconti
Dim ONO As Double, ACCT As Double, CRED As Double, Percorso As String, filenumberS As Integer, NACC As Integer, StaSched As Boolean
Dim filenumberV As Integer, rigam As Integer
Dim LISTA()
Dim SCHEDA As schede
Percorso = UserForm1.TextBox6.Value
filenumberS = FreeFile
Open Percorso & "SCHEDE" & "\SCHEDA" & codiclie & ".DAT" For Random As #filenumberS Len = Len(SCHEDA)
Get #filenumberS, NSH, SCHEDA
NACC = CInt(SCHEDA.NACCONTI)
ONO = CDbl(SCHEDA.ONORARI)
StaSched = CBool(SCHEDA.Stato)
Close #filenumberS
UserForm4.TextBox14.Value = Format(ONO, "€ #,##0.00")
ACCT = 0
If NACC > 0 Then
UserForm4.ListBox1.ControlTipText = "Doppio click sulla riga per modificare i dati"
UserForm4.CommandButton2.Enabled = True
ReDim LISTA(NACC - 1, 7)
Else
UserForm4.ListBox1.ControlTipText = ""
UserForm4.CommandButton2.Enabled = False
GoTo VISUALIZZA
End If
filenumberV = FreeFile
Open Percorso & "SCHEDE" & "\VERSAMENTI" & codiclie & "." & NSH For Random As #filenumberV Len = Len(VERSAMENTI)
For rigam = 0 To NACC - 1
Get #filenumberV, rigam + 1, VERSAMENTI
LISTA(rigam, 0) = rigam + 1
LISTA(rigam, 1) = VERSAMENTI.DataPag
LISTA(rigam, 2) = Format(VERSAMENTI.ACCONTON, "€ #,##0.00")
LISTA(rigam, 3) = Format(VERSAMENTI.ACCONTOF, "€ #,##0.00")
LISTA(rigam, 4) = CInt(VERSAMENTI.CONTRIBUTO)
LISTA(rigam, 5) = CInt(VERSAMENTI.IVA)
LISTA(rigam, 6) = CInt(VERSAMENTI.RITACC)
LISTA(rigam, 7) = Format(VERSAMENTI.Spese, "€ #,##0.00")
ACCT = ACCT + CDbl(VERSAMENTI.ACCONTON) + CDbl(VERSAMENTI.ACCONTOF) + CDbl(VERSAMENTI.Spese)
Next rigam
Close #filenumberV
UserForm4.ListBox1.List() = LISTA
VISUALIZZA:
CRED = ONO - ACCT
UserForm4.CheckBox3.Value = StaSched
If StaSched = True Then
UserForm4.CheckBox3.Caption = "Chiusa"
UserForm4.CommandButton1.Enabled = False
Else
UserForm4.CheckBox3.Caption = "Aperta"
UserForm4.CommandButton1.Enabled = True
End If
UserForm4.TextBox15.Value = Format(ACCT, "€ #,##0.00")
UserForm4.TextBox16.Value = Format(CRED, "€ #,##0.00")
End Sub
Public Type schede ' 3 Definisce il tipo dell'utente.
RECCLIENTE As Integer
NSCHEDA As Integer
nominativo As String * 40
DataInc As String * 10
ONORARI As Double
PRESTAZIONE As String * 500
NACCONTI As Integer
TipoA As Integer
AreaS As Integer
Notafatt As String * 35
Stato As Boolean
End Type
Public Type acconti ' 4 Definisce il tipo dell'utente.
RECLIEN As Integer
NSCHEDA As Integer
DataPag As String * 10
ACCONTOF As Double
ACCONTON As Double
CONTRIBUTO As Integer
IVA As Integer
Spese As Double
RITACC As Integer
Notafatt As String * 35
End Type
L'errore si verifica nel rigo 10 del codice.
Leggendo l'articolo ufficiale su questo errore, mi sembra di capire che la dimensione del file si modifica in fase di memorizzazione dei record (Put), ma non dovrebbe mantenere le dimensioni impostate nella struttura del file?
Grazie
Giorgio