Question Syntax Error For Loop

Harris00

Member
Joined
Feb 27, 2009
Messages
9
Programming Experience
3-5
VB.Net 2002 - Framework 1.0
I have below code and getting syntax error in For Loop at "To"
Dim i as Integer=0
Dim j as Integer=99
For i To j
al.Add(i)
Next

Error is at To in For loop. Any Ideas what i am doing wrong?

Regards

Harris
 
Last edited by a moderator:
For...Next Statement (Visual Basic)
As you see the basic For-Next statement is composed like this: "For counter = start To end", and you're missing the counter variable.

Set your framework/version in forum profile, or in post if it differs from main one. I changed the thread title (where that don't belong).
 
THanks for the prompt reply John
I changed it to below

For i As Integer = 0 To 99
al.Add(i)
Next

and getting error at As keyword?
 
Rumour has it in VB 2002 one couldn't declare the counter that way, you would have to declare the counter variable first, then use it in the For statement. Why don't you use a more modern IDE? VB Express 2008 is free.
 
Back
Top