Sample code for decision constructs
Private Sub btnifthen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnifthen.Click
Dim intnum% = CInt(InputBox("enter a number", "ifthen"))
If intnum > 10 Then
lblsample.Text = "hello"
ElseIf intnum < 10 Then
lblsample.Text = "hi"
Else
lblsample.Text = "equal"
End If
End Sub
Private Sub btnselect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnselect.Click
Dim intnum% = CInt(InputBox("enter a number", "select case"))
Select Case intnum
Case 2, 4, 6, 8, 10
lblsample.Text = "even less equal to ten"
Case 1, 3, 5, 7, 9
lblsample.Text = "odd less than ten"
Case 100 To 300 ' if intnum >= 100 and intnum <= 300
lblsample.Text = "range form 100 to 300"
Case Is > 25, 10 + 10 ' if intnum >25
lblsample.Text = "greater than 25"
Case Else
lblsample.Text = "any input"
End Select
End Sub
Private Sub btninline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btninline.Click
Dim intnum% = CInt(InputBox("enter a number", "in line"))
If intnum = 10 Then lblsample.Text = "hi" : intnum += 3 : lblsample.Text = intnum
End Sub
Private Sub btniif_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btniif.Click
Dim intnum% = CInt(InputBox("enter a number", "IIF"))
'Dim STRNAME$
lblsample.Text = IIf(intnum = 10, "hello", "hi")
End Sub
Private Sub BTNCHOOSE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNCHOOSE.Click
Dim intnum% = CInt(InputBox("enter a number", "cHOOSE"))
lblsample.Text = Choose(intnum, "first", "esecond", "third", "fourth")
End Sub
Private Sub lstitems_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstitems.SelectedIndexChanged
Dim intans% = lstitems.SelectedIndex
Select Case intans
Case 0
lblsample.Text = "logfor"
Case 1
lblsample.Text = "ilovedbmsverymuch"
Case 2
lblsample.Text = "webprog"
Case 3
lblsample.Text = "thesis"
End Select
End Sub
Private Sub cboitems_click(ByVal sender As Object, ByVal e As System.Windows.Forms.UICuesEventArgs) Handles cboitems.ChangeUICues
Dim intans% = cboitems.SelectedIndex
lblsample.Text = Choose(intans, "logfor", "ilovedbmsvermuch", "webprog", "thesis")
End Sub
Private Sub cboitems_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboitems.SelectedIndexChanged
Dim intans% = cboitems.SelectedIndex
lblsample.Text = Choose(intans + 1, "logfor", "ilovedbmsvermuch", "webprog", "thesis")
End Sub
Private Sub btnreset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnreset.Click
If rdogender.Checked = True Then
rdogender.Checked = False
End If
End Sub
Private Sub rdogender_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdogender.Click
lblsample.Text = "male"
End Sub
Private Sub chkvalue_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkvalue.CheckedChanged
lblsample.Text = "selected"
End Sub
End Class