Switch Function Example

The example returns the name of a language that matches the name of a city.  To try this example, draw a text box and a label on a new form.  Set the AutoSize property of the label to True.  Copy the code into the Declarations section of the form, and press F5 to run the program.

Enter the name of a city in the text box and click the form.

Sub Form_Click ()
  Label1.Caption = "Language: " & Switch(Text1.Text = "London", "English", Text1.Text = "Rome", "Italian", Text1.Text = "Paris", "French")
End Sub