Re: Need advise in for loop
vb Code:
'create a User Defined Type to hold the parameters
Private Type tIOCommand
sCmd as String
lValA as Long
lValB as Long
End Type
Dim wtCmds() as tIOCommand 'declare a variable as the type
ReDim wtCmds(num_of_commands -1) 'dimension array, in case you have multiple lists
'init the values
wtCmds(0).sCmd = "A1"
wtCmds(0).lValA = 102
wtCmds(0).lValB = 13
'etc... do this for all of them... incrementing the index for each
Static lResumeOn as Long
Dim i as Long
'Private? bolCancel as Boolean
'check to make sure it's valid...
If lResumeOn > UBound(wtCmds) then lResumeOn = 0
For i = lResumeOn to UBound(wtCmds)
Write_Text(wtCmds(i).sCmd, wtCmds(i).lValA, wtCmds(i).lValB
DoEvents
If bolCancel = True then
lResumeOn = i + 1
Exit Sub
End If
Next i
'reset resume on
lResumeOn = 0
Experiment with that.