'If...Then...Else Statement
'
'Conditionally executes a group of statements, depending on the value of an expression.
'
'Syntax
'
'If Condition Then [statements] [Else elsestatements]
'
'Or, you can use the block form syntax:
'
'If Condition Then
'[statements]
'
'[ElseIf condition-n Then
'[elseifstatements]
'
'...
'
'
'[Else
'[elsestatements]]
'
'End If
'
'The If...Then...Else statement syntax has these parts:
'
Option Explicit
'IF Statement, display message as user inputs
Sub TestIfStatement()
Dim mnt As Integer
mnt = InputBox("Enter the month in number.")
If mnt >= 13 Or mnt <= 0 Then Exit Sub
If mnt <= 3 Then
MsgBox "Thandi hai Bhai"
ElseIf mnt <= 7 Then
MsgBox "Garmi hai Bhai"
Else
MsgBox "Barish hai Bhai"
End If
End Sub
'
'Conditionally executes a group of statements, depending on the value of an expression.
'
'Syntax
'
'If Condition Then [statements] [Else elsestatements]
'
'Or, you can use the block form syntax:
'
'If Condition Then
'[statements]
'
'[ElseIf condition-n Then
'[elseifstatements]
'
'...
'
'
'[Else
'[elsestatements]]
'
'End If
'
'The If...Then...Else statement syntax has these parts:
'
Option Explicit
'IF Statement, display message as user inputs
Sub TestIfStatement()
Dim mnt As Integer
mnt = InputBox("Enter the month in number.")
If mnt >= 13 Or mnt <= 0 Then Exit Sub
If mnt <= 3 Then
MsgBox "Thandi hai Bhai"
ElseIf mnt <= 7 Then
MsgBox "Garmi hai Bhai"
Else
MsgBox "Barish hai Bhai"
End If
End Sub
No comments:
Post a Comment