Customer Login
.
Webmail Login
.
About Us
.
Contact Us
Go to:
Articles List
Looping Logic Part 1 : For...Next Statements
[
Part 1
|
Part 2
|
Part 3
|
Part 4
]
When you want to loop through an array or something else, the For loop is often the easiest way to do this. The syntax for the For loop is:
For CounterVar = FromCount to EndCount
'what you want to do
Next
And now for an example:
For i = 1 to 5
Response.Write("i=" & i & "<br>")
Next
Result:
i=1
i=2
i=3
i=4
i=5
Here is another example looping through an array and printing out it's contents, element by element.
myArr = Array("apples","oranges","grapes","peaches","watermelon") For i = 0 to 4
Response.Write("myArr(" & i & ") = " & myArr(i) & "<br>")
Next
Result:
myArr(0) = apples
myArr(1) = oranges
myArr(2) = grapes
myArr(3) = peaches
myArr(4) = watermelon
Remember that arrays in ASP start with 0.
•
High Assurance SSL. Try it for Free!
•
Need A Merchant Account?
Get Brinkster Charge!
•
Build Your Own Photo Ablum. It's Free!
•
Start Your Own Email Marketing Campaign
For as Little as
$9.95/mo
.
•
Linux Packages From
$4/mo
•
Windows Packages From
$4/mo
Home
|
Domains
|
Shared Hosting
|
Dedicated Hosting
|
Partner
|
Support
|
About Us
|
Webmail
Copyright ©
Brinkster Communications Corporation
All Rights Reserved.
Privacy Policy
|
Legal
|
Contact Us
X Close
Click Here
to get online Live Help.
Click Here
to get support using Skype.
Don't have Skype,
click here
to download for FREE.