Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lottery dilemma-control arrays

Status
Not open for further replies.

VbAche

Programmer
Nov 28, 1999
8
US
Hello
I am a VB student and have a little homework problem I need some help on. It is a lottery program in which there are three different lotto games to play. (Lotto - 6 numbers, Fantasy-5 numbers, Pick 4 - 4 numbers) Whenever the user wants to get lotto numbers the program will generate a set of random numbers. In additon, no duplicate numbers are allowed in Lotto or Fantasy. I need to display the lotto numbers in labels inside of shape controls. I am suppose to use control arrays for the shape controls which I have done on my multiple form project. One form for each lottery game the user wants to play, with a StartUp form for the selection of which game you want to play. On the StartUp form I need to offer a menu. This menu offers the user a choice of colors for the shapes and fonts for the controls on the form which has the game they wish to play. (ie - the goal is to have the menu change the controls on the form which has the game). I am using For - Next statements but it just isn't working correctly and I can't get the menu options to work at all. My code must be wrong.

I would greatly appreciate your help in helping me in my code woes.

Thanks so very much !!!

VbAche
[sig][/sig]
 
Paste your code and give examples of what the code is doing and what you want it to do. [sig]<p>Simon<br>[/sig]
 
VbAche:
I think this code will get you started.
On your form, place an array of three Option buttons and set their Index
to 1 thru 3 (default would be 0-2). Leave the default name. Change the Caption
property to: Index(1) = Pick 4, Index(2) = Fantasy 5 and Index(3) = Lotto 6.
Place three command buttons on the form named cmdSpin, cmdReset and cmdQuit.
Set their Caption property to Spin, Reset and Quit.
Place an array of six Shape objects on the form and change their Index property
to 1 thru 6. Leave the default name.
Create an array of six Label objects and place one inside each Shape. Again the
name property should be left as default. The Index must be reset to 1 thru 6.
Also Visible property of each array element (Shape and Label) should be set
to &quot;False&quot;.
You did not specify a range of random numbers, so I used 1 to 100, you can
change that in the code.
If you have any problems or need additional assistance, please post your question.

HTH
Rowland
_____________________________________
Option Explicit
_____________________________________
Private Sub cmdQuit_Click()
End
End Sub
_____________________________________
Private Sub cmdReset_Click()
Dim i As Integer

For i = 1 To 6
Shape1(i).Visible = False
Label1(i).Visible = False
Next i
End Sub
_____________________________________
Private Sub cmdSpin_Click()
Dim lFirstLoop As Integer
Dim lSecondLoop As Integer
Dim naRandIndexArray(1 To 100)
Dim RandIndex As Integer
Dim RandIndexOK As Boolean
Dim WhichGame As Integer
Dim i As Integer

If Option1(1) Then WhichGame = 4
If Option1(2) Then WhichGame = 5
If Option1(3) Then WhichGame = 6
For i = 1 To WhichGame
Shape1(i).Visible = True
Label1(i).Visible = True
Next i
Randomize
For lFirstLoop = 1 To WhichGame
RandIndex = Int(101 * Rnd)
For lSecondLoop = 1 To lFirstLoop
If RandIndex <> naRandIndexArray(lSecondLoop) Then
RandIndexOK = True
Else
RandIndexOK = False
lFirstLoop = lFirstLoop - 1
Exit For
End If
Next lSecondLoop
If RandIndexOK Then
naRandIndexArray(lFirstLoop) = RandIndex
Debug.Print lFirstLoop; naRandIndexArray(lFirstLoop)
Label1(lFirstLoop) = naRandIndexArray(lFirstLoop)
End If
Next lFirstLoop
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top