Low cost ecommerce web development India flash website design

For-Next Loops

The syntax is as follows <% For I = 1 to 10 Response.Write "Number = " & I & vbCrLf 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 vbCrLf Next %> 17 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. More about that later.) 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. Finally, VBScript also allows the Step keyword to modify the interval or stepsize of the For-loop variable. <% For I = 1 to 10 Step 2 Response.Write "Number = " & I & vbCrLf Next %> gives you: Number = 1 Number = 3 Number = 5 Number = 7 Number = 9 The loop counted I in steps of 2, thus taking on only odd values from the entire set of 10.

freelance web designer India web development

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73