1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 4 - Working With Menus and Dialog Boxes - Part 3

By Dan Mabbutt, About.com

4 of 10

The Music Trivia Solution Code - Page 3

Private Sub Button3_Click( _
  ByVal sender As System.Object, _
  ByVal e As System.EventArgs) _
  Handles Button3.Click
  Randomize()
  IndexValue = Int((Rnd() * 3) + 1)
  Debug.Write("IndexValue:" & CStr(IndexValue) & vbCrLf)
  If IndexValue = 1 Then
    Label1.Text = _
      "How do you make a cello sound beautiful?"
    RadioButton1.Text = _
      "Play ""Far, Far Away"""
    RadioButton2.Text = _
      "Sell it and buy a violin"
    RadioButton3.Text = _
      "Play it during the ""1812 Overture"""
  End If
  If IndexValue = 2 Then
    Label1.Text = _
      "How do you fix a broken tuba?"
    RadioButton1.Text = _
      "With a tuba glue"
    RadioButton2.Text = _
      "How do you tell it's broken?"
    RadioButton3.Text = _
      "Who would want to fix it?"
  End If

4 of 10

Explore Visual Basic

More from About.com

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Working With Menus and Dialog Boxes - Part 3

©2008 About.com, a part of The New York Times Company.

All rights reserved.