Wednesday, February 9, 2011

Case Statement

■A case statement
 Public Class Form1
  
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  
     'Declare variables    
  
     Dim strSnack As String
  
     Dim strDinner As String
  
     strSnack = TextBox1.Text
  
     Select Case strSnack
  
       Case "Had a Snack"
  
         strDinner = "Will not have"
  
       Case "Had a little"
  
         strDinner = "Will have a little"
  
       Case Else
  
         strDinner = "Will have"
  
     End Select
  
     MessageBox.Show(strDinner & " Dinner.")
  
   End Sub
  
 End Class  

No comments:

Post a Comment