Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

expected end of statement error: Dim or For line

Status
Not open for further replies.

snowxf

Technical User
Jan 5, 2005
20
0
0
US
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:
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
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??
 
Response.Write BR & "<table>" & BR _

Dim counter
counter = 0

whats with the _ continuation at the end?????
 
:D Thanks! Oh man, that was when I had the other Response.Write lines following it, before I broke it up to add in the If statements, and the For statements...and I just didn't notice it. Thank you kindly!

^.,.^
Jaime
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top