heads or tails

Heads or Tails simalates a coin toss, its a simple program and a good one to learn.

Add a Command1 and Label1

Command1: Caption = "Flip"

Label1: Caption = "" (blank)

 

Double Click the button and insert the following:

Private Sub Command1_Click()

Label1.Caption = Int(Rnd * 3)

If Label1.Caption = "1" Then Label1.Caption = "Heads"

If Label1.Caption = "2" Then Label1.Caption = "Tails"

If Label1.Caption = "0" Then Label1.caption = Int(Rnd *3)

End Sub

Int(Rnd * 3) picks a number 0,1 or 2. If 1, then Label1 = Heads and if 2 then Label2 = Tails

In the form add the following:

Private Sub Form_Load()
Randomize
End Sub

Randomize will keep the Rnd from going in a certain pattern.

If you have any problems e-mail me at vbx23@aol.com