Sunday, December 19, 2010

If Then Else If Statement

Previous Next



We can test for more than one condition using the if..else if conditional statement. You use the following syntax in an if..else if statement:

Syntax:

If Then
Block of the statement1
Else If Then
Block of the statement2
Else If Then
Block of the statement3
Else
Block of the statement4
End If


Example

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click



Dim a, b, c As Integer


a = InputBox("Enter the value for A")
b = InputBox("Enter the value for B")
c = InputBox("Enter the value for C")


If a = b Then
MsgBox("A is Equal to B" )
ElseIf a > b Then

MsgBox("A is greater then B" )
ElseIf a <>