VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create a user specified number of random numbers and put them in a list box.

by Thomas Bowler (2 Submissions)
Category: Math/Dates
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 14th June 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Create a user specified number of random numbers and put them in a list box.

Rate Create a user specified number of random numbers and put them in a list box.



'Create a Text box called Text1
'Create a List box called List1
'Create a Text box called create (this is the box that the users puts
'the number of random numbers they want generated)
Private Sub Generate_Click()
' This code creates a random number between 1 and 9
' It will keep creating random numbers until the
' number of numbers in the list is equal to the
' number specified in the create.Text box
' The random number will be shoved into Text1.Text
' When Text1.Text changes, the value of Text1.Text is
' added to the list
Do
Randomize
   Dim t1 As Integer
   t1 = Int(Rnd(1) * 9)
   Text1.Text = CStr(t1)
Loop Until List1.ListCount = create.Text
End Sub

Private Sub Text1_Change()
List1.AddItem Text1.Text
End Sub

Download this snippet    Add to My Saved Code

Create a user specified number of random numbers and put them in a list box. Comments

No comments have been posted about Create a user specified number of random numbers and put them in a list box.. Why not be the first to post a comment about Create a user specified number of random numbers and put them in a list box..

Post your comment

Subject:
Message:
0/1000 characters