VBS for next loop
-
I'm new in VBs.. i've got this code:
For i = 0 To 20 Step 1.0
MsgBox "Blubb"& i &"bla"
Next iand this error: 800A0401 "Statement completion expected" "Compile error in Microsoft VBScript"
-
I'm new in VBs.. i've got this code:
For i = 0 To 20 Step 1.0
MsgBox "Blubb"& i &"bla"
Next iand this error: 800A0401 "Statement completion expected" "Compile error in Microsoft VBScript"
What's with
Hide Copy Code
? Comment that out....
-
What's with
Hide Copy Code
? Comment that out....
sry that was a mistake, i don't have this in my code... it was a copy and paste error -.- now my code is right
-
sry that was a mistake, i don't have this in my code... it was a copy and paste error -.- now my code is right
Well, unless it's another copy/paste error, you should space out your &'s wrong:
MsgBox "Blubb"& i &"bla"
right:
MsgBox "Blubb" & i & "bla"
-
Well, unless it's another copy/paste error, you should space out your &'s wrong:
MsgBox "Blubb"& i &"bla"
right:
MsgBox "Blubb" & i & "bla"
okay, thank you but the error is still comming it have to be the loop, cause i now only have
For i = 0 To 20 Step 1.0
Next i
and the error is still comming
-
I'm new in VBs.. i've got this code:
For i = 0 To 20 Step 1.0
MsgBox "Blubb"& i &"bla"
Next iand this error: 800A0401 "Statement completion expected" "Compile error in Microsoft VBScript"
See For...Next Statement[^] and MsgBox Function[^].
-
See For...Next Statement[^] and MsgBox Function[^].
i just looked at this, but i do not find a mistake in my code
-
okay, thank you but the error is still comming it have to be the loop, cause i now only have
For i = 0 To 20 Step 1.0
Next i
and the error is still comming
Well try setting the "step" to just 1 rather than 1.0 Presumably you have defined that as an Integer? And you can remove the final i after Next.
-
Well try setting the "step" to just 1 rather than 1.0 Presumably you have defined that as an Integer? And you can remove the final i after Next.
i just ignor the step, it doesnt matter if it says "step 1" or nothing, 1 is the default value
-
i just ignor the step, it doesnt matter if it says "step 1" or nothing, 1 is the default value
So now you're saying
For i = 0 To 20
Next i
is giving you an error? I don't think so... unless you have not defined the variable i at all.
-
i just looked at this, but i do not find a mistake in my code
-
So now you're saying
For i = 0 To 20
Next i
is giving you an error? I don't think so... unless you have not defined the variable i at all.
This:
Dim i as Integer
for i = 0 To 20
' MsgBox "Blubb" & i & "bla"
' ticketno = Replace(ticketno,"("& i & ")","")
Nextor this
Dim i
for i = 0 To 20
' MsgBox "Blubb" & i & "bla"
' ticketno = Replace(ticketno,"("& i & ")","")
Nextis showing the error
-
oh thankyou but that wasnt the error at all
-
This:
Dim i as Integer
for i = 0 To 20
' MsgBox "Blubb" & i & "bla"
' ticketno = Replace(ticketno,"("& i & ")","")
Nextor this
Dim i
for i = 0 To 20
' MsgBox "Blubb" & i & "bla"
' ticketno = Replace(ticketno,"("& i & ")","")
Nextis showing the error
Well, the first will - you don't DIM variables with the As [type] in VBS. You could try
Dim i%
but other than that, and capitalizing the F in for, which shouldn't really be necessary, I really find it hard to believe that this is where the error really lies. You need to pin down the exact line.....
-
I'm new in VBs.. i've got this code:
For i = 0 To 20 Step 1.0
MsgBox "Blubb"& i &"bla"
Next iand this error: 800A0401 "Statement completion expected" "Compile error in Microsoft VBScript"
-
-
This:
Dim i as Integer
for i = 0 To 20
' MsgBox "Blubb" & i & "bla"
' ticketno = Replace(ticketno,"("& i & ")","")
Nextor this
Dim i
for i = 0 To 20
' MsgBox "Blubb" & i & "bla"
' ticketno = Replace(ticketno,"("& i & ")","")
Nextis showing the error
The key point you are missing here is that it is not actually the same error! If I paste your original code into t1.vbs I get the following error
C:\Temp\t1.vbs**(3, 6)** Microsoft VBScript compilation error: Expected end of statement
Removing the
i
after theNext
fixes that problem (as suggested by @Wombaticus) If I do the same thing with your first block of code above I getC:\Temp\t1.vbs**(1, 7)** Microsoft VBScript compilation error: Expected end of statement
...getting rid of the
as Integer
fixes that one (as suggested by @Wombaticus) Your second block of code above does not produce anything - neither error nor output. If you were getting an error there are you sure you remembered to save the changes in your editor before attempting to run the script file? We've all done that a few times :laugh: However, to get to the point ... See those numbers in brackets in my error messages above that are in bold? They indicate the ROW and COLUMN that the error occurs in - so the error moved from line 3 in the first example to line 1 in the second. Much easier to find the problem when you know that little bit of extra infomation -
oh thankyou but that wasnt the error at all
-
What's with
Hide Copy Code
? Comment that out....
Thank you very much.... i don't even know what the error was. I had to restart the server, and now it works without doing anything :D but thank you :D