Sunday, April 2, 2017

If Statement

'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

No comments:

Post a Comment

*INTERVIEW QUESTIONS

* Ques 01. What is the difference between ByVal and ByRef and which is default ? Ans-  ByRef : If you pass an argument by reference when...