Page 201 - DCAP408_WEB_PROGRAMMING
P. 201
Unit 7: Introduction to ASP (Active Server Pages)
Response.Write “Number = “ & I & vbCrLf Notes
Next
%>
And the output ...
Number = 1
Number = 2
Number = 3
Number = 4
Number = 5
Number = 6
Number = 7
Number = 8
Number = 9
Number = 10
The vbCrLf used in the statement above is a predefined constant that equals the combination of
the Carriage-Return character (CR for short), and the Line Feed character (LF for short.) Using it
causes the output to continue on the next line.
Without the vbCrLf, our output would have appeared on one long line:
Number = 1Number = 2Number = 3Number = 4Number = 5Number = 6Number
= 7Number = 8Number = 9Number = 10
Let us take a case of nested loops to clarify things:
<%
For I = 1 to 8
For j =1 to 8
Response.Write “X”\
Next
Response.Write vbCrL
Next
%>
This will draw a nice chessboard pattern on the screen. (You will need to view the source of the
page in your browser however. If you look at the page in the browser itself, you will not see the
true result.)
Notes A very important point to note is that the Next statement that completes the For
does not take an argument. You cannot say:
Next I
Or
Next J
This is invalid. Each Next statement encountered is automatically assumed to complete
the immediately preceding For statement.
LOVELY PROFESSIONAL UNIVERSITY 195