Is there a "FOR/NEXT" loop problem ?

dan kabestan

Member
Licensed User
Would you see the following script sample :
i put 2 cascaded loops and the second one must
modify the limit of the first. So :

'----------------------------------------
Sub Globals
'listbox1 declared.
'tn = 0
'tm = 0
End Sub
'--------------------------------------
Sub App_Start
Form1.Show
test
End Sub
'------------------------------------
Sub test
tn=50
tm=5
n=0
For n = 0 To tn
For m = 0 To tm
If tm<7 Then : tm = tm+1 : End If
If tn<100 Then : tn = tn+1 : End If
Next
listbox1.Add("n=" & n & " tn=" & tn & " tm=" & tm)
Next
listbox1.Add("fin ---- n=" & n & " tn=" & tn & " tm=" & tm)
End Sub
'----------------------------------

Result, (with tn and tm global or not) :
tm is modified, BUT, tn is not !
(a '51' stop is curious !)
Is it a kind of ADA-like safety limit ?
Sure, one solution is to replace first loop by a DO/WHILE,
but is it really normal ? where is my wrong ?
Thank's for help
denis
 
Top