If Then Else Statement

 If Then Else statement is a control structure which executes different set of code statements when the given condition is true or false.

Syntax: 
If [Condition] Then
   [Statements]
Else
   [Statements]

In the above syntax when the Condition is true, the Statements after Then are executed.If the condition is false then the statements after the Else part is executed.

Example:
 Private Sub Button1_Click(ByVal sender As System.Object,
       ByVal e As System.EventArgs) Handles Button1.Click
   If Val(TextBox1.Text) >= 40 Then
      MsgBox("GRADUATED")
        Else
      MsgBox("NOT GRADUATED")
   End If
 End Sub

No comments:

Post a Comment