


- If … Then … Statement
- If … Else … Then Statement
- If … Else If … Else … Then Statement or Nested If
- Select … Case … Statement
If … Then Statement:
Description:


Syntax:
If Expression Then
Statement1
Statement2
……………..
……………..
StatementN
End If
Example:
If strName = “Testing” Then
MsgBox(“Testing”)
End If
If … Else … Then Statement:
Description:


Syntax:
If Expression Then
Statement1
Statement2
……………..
……………..
StatementN
Else
Statement1
Statement2
……………..
……………..
StatementN
End If
Example:
If Num1 > Num2 Then
MsgBox(“Num1 is Big”)
Else
MsgBox(“Num2 is Big”)
End If
If … ElseIf … Else … Then Statement or Nested If:
Description:






Syntax:
If Expression Then
Statement1
Statement2
……………..
……………..
StatementN
Else If Expression Then
Statement1
Statement2
……………..
……………..
StatementN
Else
Statement1
Statement2
……………..
……………..
StatementN
End If
Example:
If value = 0 Then
Message = “zero”
ElseIf value = 1 Then
Message = “one”
Else
Message = "Value out of range!"
End If
Select Case Statement or Nested If:
Description:






Syntax:
Select Case Expression
Case Expression1
Statement1
Statement2
……………..
……………..
StatementN
Case Expression2
Statement1
Statement2
……………..
……………..
StatementN
Case Expression3
Statement1
Statement2
……………..
……………..
StatementN
Case Expression4
Statement1
Statement2
……………..
……………..
StatementN
Case Else
Statement1
Statement2
……………..
……………..
StatementN
End Select
Example:
Select Case strColor
Case "Red"
MsgBox (“Red”)
Case "Blue"
MsgBox (“Blue”)
Case "Black"
MsgBox (“Orange ”)
Case "Blue sky"
MsgBox (“Black”)
Case "Yellow"
MsgBox (“Green”)
Case Else
MsgBox (“Check the Option you Provided or Spelling”)
End Select
No comments:
Post a Comment