• Log in or sign up for an account here: https://www.sythe.org/login

Help with Random Numbers

tomanderson12

Member
Joined
Jan 21, 2008
Sythe Gold
0
Messages
53
Hello guys, I have a problem I have a program that is the generate random numbers but not the same one again I thought I had it with this but all it does is display the same number again in the 6 text boxes i have which are all control arrays by the way

So basically when you click cmdRun it generates random numbers into 6 text boxes called txtMachine which are control arrays, but it doesn't generate random numbers in each its the same one for all the boxes

the code is

Code:
Private Sub cmdRun_Click()

  ' Dimension the variables used in the programme
    Dim intNumber As Integer
    Dim arrNumber(0 To 5) As Integer
    Dim count As Integer
    Dim i As Integer
    Dim x As Integer
    Dim y As Integer
    
    
    
        'Sets Count
        For x = 0 To 5
        
        

            Randomize
            
            intNumber = Int(Rnd * 49) + 1 ' Random number 1 to 49
            For y = 0 To 5
                ' Check arrNumber (y)
                'If intnumber has already been selected,
                'Then go and select another one.
            If intNumber = arrNumber(y) Then

                End If
                
            Next y

                arrNumber(x) = intNumber
            
                txtMachine(count).Text = (arrNumber(i))
                count = i + 1
            Next x
        
        '----------------------------------------------------
        
        For i = 0 To 5
            
        Next
        

End Sub
 
This should work, if you need anything explained just post back.
Code:
Private Sub cmdRun_Click()

    'Dimension the variables used in the programme
    Dim intNumber As Integer
    Dim arrNumber(0 To 5) As Integer
    Dim intCount As Integer
    Dim intCheck As Integer
    
        'Sets Count
        For intCount = 0 To (txtmachine.count - 1)
        
            Randomize
            intNumber = Int(Rnd * 49) + 1 ' Random number 1 to 49
            arrNumber(intCount) = intNumber
            
            If intCount > 0 Then
            
ReCheck:
            
                For intCheck = 0 To intCount - 1
                
                    If intNumber = arrNumber(intCheck) Then
                    
                        intNumber = Int(Rnd * 49) + 1
                        arrNumber(intCount) = intNumber
                        GoTo ReCheck
                        
                    End If
                    
                Next intCheck
                
            End If
            
            txtmachine(intCount).Text = intNumber
                
        Next intCount

End Sub
 
Runescape Gamblingrunescape gambling
Back
Top