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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with programe please

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello i have just started studying visual basics and i had a programme to design i have designed it all got it nearly all working except that the programme i have done is a lotary programme and it generates 6 random numbers 1 to 49 but i cant figure out how to set the programme so two numbers are not the same also to set the programe so the ball show in numeric order i.e 1, 5, 9, 14, 17,43, not 5,43,17,9,1,14. I have copy my code on here


Option Explicit

Private Sub Command1_Click()
Randomize
Label1.Caption = Int((49 * Rnd) + 1)
Label2.Caption = Int((49 * Rnd) + 1)
Label3.Caption = Int((49 * Rnd) + 1)
Label4.Caption = Int((49 * Rnd) + 1) 'Set Labels to generate
Label5.Caption = Int((49 * Rnd) + 1) 'random numbers from
Label6.Caption = Int((49 * Rnd) + 1) '1 to 49 _
=================================================================
'SET UP FOR BALL ONE COLOR'S
If (Label1.Caption >= 1 And Label1.Caption <= 9) Then
Shape1.FillColor = QBColor(15)
Label1.BackColor = QBColor(15)

ElseIf (Label1.Caption >= 10 And Label1.Caption <= 19) Then
Shape1.FillColor = QBColor(11)
Label1.BackColor = QBColor(11)

ElseIf (Label1.Caption >= 20 And Label1.Caption <= 29) Then
Shape1.FillColor = QBColor(12)
Label1.BackColor = QBColor(12)

ElseIf (Label1.Caption >= 30 And Label1.Caption <= 39) Then
Shape1.FillColor = QBColor(10)
Label1.BackColor = QBColor(10)

ElseIf (Label1.Caption >= 40 And Label1.Caption <= 49) Then
Shape1.FillColor = QBColor(14)
Label1.BackColor = QBColor(14)
End If 'End of ball one setup _
=================================================================


'SET UP OF BALL TWO COLOR'S
If (Label2.Caption >= 1 And Label2.Caption <= 9) Then
Shape2.FillColor = QBColor(15)
Label2.BackColor = QBColor(15)

ElseIf (Label2.Caption >= 10 And Label2.Caption <= 19) Then
Shape2.FillColor = QBColor(11)
Label2.BackColor = QBColor(11)

ElseIf (Label2.Caption >= 20 And Label2.Caption <= 29) Then
Shape2.FillColor = QBColor(12)
Label2.BackColor = QBColor(12)

ElseIf (Label2.Caption >= 30 And Label2.Caption <= 39) Then
Shape1.FillColor = QBColor(10)
Label1.BackColor = QBColor(10)

ElseIf (Label2.Caption >= 40 And Label2.Caption <= 49) Then
Shape2.FillColor = QBColor(14)
Label2.BackColor = QBColor(14)
End If 'END OF BALL TWO SET UP _
==================================================================

'SETUP OF BALL THREE COLOR'S

If (Label3.Caption >= 1 And Label3.Caption <= 9) Then
Shape3.FillColor = QBColor(15)
Label3.BackColor = QBColor(15)

ElseIf (Label3.Caption >= 10 And Label3.Caption <= 19) Then
Shape3.FillColor = QBColor(11)
Label3.BackColor = QBColor(11)

ElseIf (Label3.Caption >= 20 And Label3.Caption <= 29) Then
Shape3.FillColor = QBColor(12)
Label3.BackColor = QBColor(12)

ElseIf (Label3.Caption >= 30 And Label3.Caption <= 39) Then
Shape3.FillColor = QBColor(10)
Label3.BackColor = QBColor(10)

ElseIf (Label3.Caption >= 40 And Label3.Caption <= 49) Then
Shape3.FillColor = QBColor(14)
Label3.BackColor = QBColor(14)
End If 'END OF BALL THREE SETUP _
===================================================================

'SET UP FOR BALL FOUR COLOR'S

If (Label4.Caption >= 1 And Label4.Caption <= 9) Then
Shape4.FillColor = QBColor(15)
Label4.BackColor = QBColor(15)

ElseIf (Label4.Caption >= 10 And Label4.Caption <= 19) Then
Shape4.FillColor = QBColor(11)
Label4.BackColor = QBColor(11)

ElseIf (Label4.Caption >= 20 And Label4.Caption <= 29) Then
Shape4.FillColor = QBColor(12)
Label4.BackColor = QBColor(12)

ElseIf (Label4.Caption >= 30 And Label4.Caption <= 39) Then
Shape4.FillColor = QBColor(10)
Label4.BackColor = QBColor(10)

ElseIf (Label4.Caption >= 40 And Label4.Caption <= 49) Then
Shape4.FillColor = QBColor(14)
Label4.BackColor = QBColor(14)
End If 'END OF BALL FOUR SETUP _
==================================================================

'SET UP FOR BALL FIVE COLOR'S

If (Label5.Caption >= 1 And Label5.Caption <= 9) Then
Shape5.FillColor = QBColor(15)
Label5.BackColor = QBColor(15)

ElseIf (Label5.Caption >= 10 And Label5.Caption <= 19) Then
Shape5.FillColor = QBColor(11)
Label5.BackColor = QBColor(11)

ElseIf (Label5.Caption >= 20 And Label5.Caption <= 29) Then
Shape5.FillColor = QBColor(12)
Label5.BackColor = QBColor(12)

ElseIf (Label5.Caption >= 30 And Label5.Caption <= 39) Then
Shape5.FillColor = QBColor(10)
Label5.BackColor = QBColor(10)

ElseIf (Label5.Caption >= 40 And Label5.Caption <= 49) Then
Shape5.FillColor = QBColor(14)
Label5.BackColor = QBColor(14)
End If 'END OF BALL FIVE SETUP _
==================================================================

'SET UP FOR BALL SIX COLOR'S

If (Label6.Caption >= 1 And Label6.Caption <= 9) Then
Shape6.FillColor = QBColor(15)
Label6.BackColor = QBColor(15)

ElseIf (Label6.Caption >= 10 And Label6.Caption <= 19) Then
Shape6.FillColor = QBColor(11)
Label6.BackColor = QBColor(11)

ElseIf (Label6.Caption >= 20 And Label6.Caption <= 29) Then
Shape6.FillColor = QBColor(12)
Label6.BackColor = QBColor(12)

ElseIf (Label6.Caption >= 30 And Label6.Caption <= 39) Then
Shape6.FillColor = QBColor(10)
Label6.BackColor = QBColor(10)

ElseIf (Label6.Caption >= 40 And Label6.Caption <= 49) Then
Shape6.FillColor = QBColor(14)
Label6.BackColor = QBColor(14)
End If 'END OF BALL SIX SETUP _
=================================================================
End Sub

Private Sub Command2_Click()
End
End Sub

thank you

 
Helo goergina im doing something similar to you and also have same problem
 
What a coincidence. Same school?

What you could do is:-

When you generate the 2nd random number do it in a loop and keep trying until you get a different one to the first. And etc.

You could have an array of 6 numbers and set them to 0. The do something like this.

for i = 0 to 5

Number(i) = randomnumber

Done = false
do until Done
Done=true
for j = 0 to i - 1
if Number(j) = Number(i) then
Number(i) = randomnumber
Done=false
exit for
endif
next j
loop

next i


Or something like that. Peter Meachem
peter@accuflight.com
 
I left school some while back. Does the idea I gave you help at all? Peter Meachem
peter@accuflight.com
 
it confused me a bit i am very new to programing and visual basics so still a bit unfirmiliar with some of the syntax in it but thank you for your help .
G
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top