You can make a decision based on user input using an If statement. The If statement tests a condition and if the result is true then it runs the code that follows the If statement but if the result is false then it runs the code after the else statement. Here is an example for when someone enters their age on a form:
Age = Request("txtAge")
if Age >= 18 then
Response.Write "You are old enough to use this site"
Response.Write "You are too young to use this site"
Select Case Statement
The Select Case statement is similar to the If statement because it also used for making decisions. The difference is that the Select Case statement can have many conditions and the code to run for when the result of each condition is true. Here is an example of choosing a country from a dropdown listbox:
Country = Request("lstCountry")
Select Case Location
Response.Write "You are from the USA"
Response.Write "You are from the UK"
Response.Write "You are from SA"
The For loop is used to loop from one number to another. The code inside the loop is repeated until the second number is reached. Here is an example of counting to 10 using a For loop:
for i = 1 to 10
The While loop checks if a condition is true before each time that the code inside the loop is repeated. The loop variable must be set before it is used in a While loop and the loop variable must be incremented inside the loop.
j = 1
While j <= 10
j = j + 1
The Do loop is the same as the While loop except that the condition is tested at the bottom instead of at the top of the loop.
k = 1
k = k + 1
loop until k > 10