Conditionally executes a group of statements, depending on the value of an expression.
If condition Then [statements] [Else elsestatements]
Or, you can use the block form syntax:
If condition Then
[ElseIf condition-n Then
The If…Then…Else statement syntax has these parts:
|condition||Required. One or more of the following two types of expressions:A numeric expression or string expression that evaluates to True or False.If condition is Null, condition is treated as False An expression of the form TypeOf objectname Is objecttype. TheObjectname is any object reference and objecttype is any valid object type.The expression is True if objectname is of the object type specified by objecttype; otherwise it is False.|
|statements||Optional in block form; required in single-line form that has no Else clause.One or more statements separated by colons; executed if condition is True.|
|condition-n||Optional. Same as condition.|
|elseif||Optional. One or more statements executed if associated condition-n is True.|
|else||Optional. One or more statements executed if no previous condition expression is True.|
Dim Number, Digits, MyString
Number = 53 ‘ Initialize variable.
If Number < 10 Then
Digits = 1
ElseIf Number < 100 Then
‘ Condition evaluates to True so the next statement is executed.
Digits = 2
Digits = 3
Ends a procedure or block.
Syntax : End, End Function, End If, End Property, End Select, End Sub, End Type, End With
When executed, the End statement resets all module-level variables and all static local variables in all modules. To preserve the value of these variables, use the Stop statement instead. You can then resume execution while preserving the value of those variables.
The End statement syntax has these forms:
|End||Terminates execution immediately. Never required by itself but may beplaced anywhere in a Procedure to end code execution, close files openedwith the Open statement and to clear|
|End Function||Required to end a Function statement.|
|End If||Required to end a block If…Then…Else statement.|
|End Property||Required to end a Property Let, Property Get, or Property Set procedure.|
|End Select||Required to end a Select Case statement.|
|End Sub||Required to end a Sub statement.|
|End Type||Required to end a user-defined type definition (Type statement).|
|End With||Required to end a With statement.|
Dim Password, Pword
PassWord = “Swordfish”
Pword = InputBox(“Type in your password”)
If Pword <> PassWord Then