Choose Function Example

The example displays a name in response to choosing an option button.  To try this example, draw a label and an option button on a blank form.  Set the Name property of the option button to "Opt" and the Index property to 0.  Paste the code over the Form_Load procedure and then press F5 to run the program.

Sub Form_Load ()
  Opt(0).Caption = "Shipper 1"
  Load Opt(1)
  Opt(1).Caption = "Shipper 2"
  Opt(1).Top = Opt(0).Top + Opt(1).Height * 1.5
  Opt(1).Visible = True
  Load Opt(2)
  Opt(2).Caption = "Shipper 3"
  Opt(2).Top = Opt(1).Top + Opt(1).Height * 1.5
  Opt(2).Visible = True
  Opt(0).Value = True
End Sub

Sub Option1_Click (Index As Integer)
  Label1.Caption = "Shipper: " & Choose(Index, "Speedy", "United", "Federal")
End Sub