Lucky Draw

 

 

I have made a lucky program that used  control arrays. This program consists of  a 3x3 matrix, which means there are 9 command buttons in a grid. One of the random buttons contains a prize, which when you click displays the word "prize" in the caption. If you don't strike the prize , the word "The Prize is here " will appear on the command button that contains the prize.

The Program Code

Private Sub Command1_Click(Index As Integer)
Dim n As Integer
For n = 0 To 8
Command1(n).Caption = ""
Next

Randomize Timer

n = Int(Rnd * 9)
If Index = n Then
Command1(n).Caption = "Prize"
Else: Command1(n).Caption = "The Prize is here"

End If

End Sub

 

 

The Interface:

 

 

 

[Back to Sample]