ASP Decision Structures

One of the most used structures in programming, the decision structure, is often used in VBScript to handle conditions. As you will notice, these structures are almost identical to the ones used in Visual Basic with the exception of the server objects.

Below is an example of the use of an If/Then Statement:


<%
'VBScript Example: If/Then Statement

Dim intFirst, intSecond

'Assign values to variables
intFirst = 12
intSecond = 7

'Determine which number is greater
If intFirst > intSecond Then
	Response.Write "The first number, " & intFirst & ", is greater."
Else
	Response.Write "The second number." & intSecond & ", is greater."
End If	
%>

Another commonly used decision structure, which is suited for decisions with numerous options, is the Select/Case Structure:


<%
'VBScript Example: Select/Case Structure (use for complicated If/Then)

Dim intFirst, intSecond

'Assign values to variable
intValue = 12

'Determine which is true
Select Case intValue
	Case 1,2,3,4,5,6,7,8,9:
	Response.Write "The integer value is less than 10."
	Case 10,11,12,13,14,15,16,17,18:
	Response.Write "The integer value is greater than or equal to 10."
	Case Else:
	Response.Write "I don't know what the heck that number is."
End Select
%>


Next