VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This little gem will create a string of randomly generated numbers from 1 to 20, with NO REPITIONS!

by terranRICH (Richard Brum) (2 Submissions)
Category: Math/Dates
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Thu 3rd October 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This little gem will create a string of randomly generated numbers from 1 to 20, with NO REPITIONS! Just create a text box (Text1) and a

Rate This little gem will create a string of randomly generated numbers from 1 to 20, with NO REPITIONS!



    Dim Sequence(1 To 20) As Integer   'This is where the numbers will be
    For i = 1 To 20                    ' stored.
redo:
        Sequence(i) = Int(Rnd * 20) + 1
        If i > 1 Then             'Check to see if any of the previous numbers
            For j = 1 To i - 1    ' are the same as Sequence(i).
                If Sequence(j) = Sequence(i) Then GoTo redo
            Next j
        End If
    Next i
    Text1.Text = ""
    For k = 1 To 20
        Text1.Text = Text1.Text & Sequence(k)
        If k < 20 Then Text1.Text = Text1.Text & ", " 'Adds commas between ea #
    Next k
End Sub

Download this snippet    Add to My Saved Code

This little gem will create a string of randomly generated numbers from 1 to 20, with NO REPITIONS! Comments

No comments have been posted about This little gem will create a string of randomly generated numbers from 1 to 20, with NO REPITIONS!. Why not be the first to post a comment about This little gem will create a string of randomly generated numbers from 1 to 20, with NO REPITIONS!.

Post your comment

Subject:
Message:
0/1000 characters