Syntax:
If <Condition> Then
Statements
Else If <Condition> Then
Statements
Else
Statements
Code:
In this program we are printing text as per input. If input is 1 then "Message 1" and if Input other than 1,2,3 then display "other".
If <Condition> Then
Statements
Else If <Condition> Then
Statements
Else
Statements
End If
Code:
In this program we are printing text as per input. If input is 1 then "Message 1" and if Input other than 1,2,3 then display "other".
Public Class Form1 Dim Message As String = "This is a message string" Dim intvar As Integer = 25 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click MessageBox.Show(Message) MessageBox.Show(intvar) End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click If TextBox1.Text = "1" Then Label1.Text = "Message 1" ElseIf TextBox1.Text = "2" Then Label1.Text = "Message 2" ElseIf TextBox1.Text = "3" Then Label1.Text = "Message 3" Else Label1.Text = "Other" End If End Sub End Class |