I'm getting an expected end of statement error on a Dim or For statement line, depending on how I've rearranged the code to try and debug it. I'm setting up an ASP page that will display a 2-column table, slowly adding in functionality (and subroutines) by just hard-coding it to test it bit by bit. It displayed fine, and then I added another Sub in my "include" page as follows:
It resulted in the following message:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/include_pillarMain.asp, line 59
Dim counter
^
If I move 'Dim counter' and 'counter=0' outside of the subroutine with the global variables, then I get the following:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/include_pillarMain.asp, line 62
For counter = 0 To 9
^
In this instance, I have commented out 'For counter = 0 To 9' and 'Next'. It displays the table fine. I also did a 'Response.Write counter' line which output 0 showing it's initialized fine. (Also works when I move the Dim statement back inside the Sub.)
Please note, I'm testing this page out using IIS on Windows XP, through IE 6.0 SP1, and BR is used as a "constant" which holds the ASCII carriage return and line feed (like vbCrLf).
Anyone know what's going on with my For loop??
Code:
Sub displayTableListings()
'{
Response.Write BR & "<table>" & BR _
Dim counter
counter = 0
For counter = 0 To 9
If (counter Mod 2 = 1) Then
Response.Write " <tr class=""blue"">" & BR _
& " <td>" & BR _
& " Hollywood East Cafe" & BR _
& " </td>" & BR _
& " <td>" & BR _
& " Edit" & BR _
& " </td>" & BR _
& " </tr>" & BR
Else
Response.Write " <tr>" & BR _
& " <td>" & BR _
& " Hollywood East Cafe" & BR _
& " </td>" & BR _
& " <td>" & BR _
& " Edit" & BR _
& " </td>" & BR _
& " </tr>" & BR
End If
Next
Response.Write "</table>" & BR
'}
End Sub
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/include_pillarMain.asp, line 59
Dim counter
^
If I move 'Dim counter' and 'counter=0' outside of the subroutine with the global variables, then I get the following:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/include_pillarMain.asp, line 62
For counter = 0 To 9
^
In this instance, I have commented out 'For counter = 0 To 9' and 'Next'. It displays the table fine. I also did a 'Response.Write counter' line which output 0 showing it's initialized fine. (Also works when I move the Dim statement back inside the Sub.)
Please note, I'm testing this page out using IIS on Windows XP, through IE 6.0 SP1, and BR is used as a "constant" which holds the ASCII carriage return and line feed (like vbCrLf).
Anyone know what's going on with my For loop??