Tuesday, February 1, 2011

Case Statement in Visual Basic

A case statement in Visual Basic:

 Public Class Form1  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim num As Double
Select Case num
Case 5
txtResults.Text = "case 1"
Case 5 To 7
txtResults.Text = "case 2"
Case 7 To 12
txtResults.Text = "case 3"
End Select
End Sub
End Class

No comments:

Post a Comment