If statement a method that makes a variable or some other type of data to make a decision. For example, you may have a
Script to check if the Boolean value is True or FALSE, or the variable contains a number or string value.
Use the IF statement to execute the statement if the logical condition is true. Use an optional other clause to execute the statement if
Condition is false. The syntax for a seemingly if statement is as follows:
If condition Then
Statements_1
Else
Statements_2
End If
The condition can be any expression with a value of true or false. If the condition is true, Statements_1 is
Line, otherwise, the statements_2 is executed. Statement_1 and statement_2 can be any statement, including
A further nested if statement.
You can also use compound declarations to elseif multiple conditions in a sequential order. You should use this building if you want to select
Multiple sets of lines to execute.
If Condition_1 Then
Statement_1
[ElseIf Condition_2 Then
Statement_2]
...
[ElseIf Condition_n_1 Then
Statement_n_1]
[Else
Statement_n]
End If
Let's take the example. The first example determines whether a student has passed a pass score of 57 exams:
Select Actionselect alltry it<%@ language= "VBScript"%>
<%
Dim result
result = 70
If result >= Then
Response.Write ("Pass <br/>")
Else
Response.Write ("Fail <br/>")
End If
%> Next example uses an if statement in ElseIf variants. This lets us test if the first other condition is not
Right. The plan will test each sequence state until:
One of its discoveries is true. In this case, the code that executes this condition.
It arrives at an else statement. In this case, the code that executes the ELSE statement.
It arrives eventually if ... elseif. else structure. In this case, moved to the next speaker, after having
The structure of the condition.
Select Actionselect alltry it<%@ language= "VBScript"%>
<%
Dim result
result = 70
If result >=-then
Response.Write ("Passed:grade A <br/>")
ElseIf result >= Then
Response.Write ("Passed:grade B <br/>")
ElseIf result >= Then
Response.Write ("Passed:grade C <br/>")
Else
Response.Write ("Failed <br/>")
End If
%>