VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create random numbers when a button is pushed and display those numbers in a text box

by Thomas Bowler (2 Submissions)
Category: Math/Dates
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Fri 6th October 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Create random numbers when a button is pushed and display those numbers in a text box

Rate Create random numbers when a button is pushed and display those numbers in a text box



Randomize
   Dim 1 As Integer
   1 = Int(Rnd(1) * 9) ' create random numbers between 1 and 9
   Text1.Text = CStr(t1) ' display random number in text box
End Sub
'If you want to put different numbers in multiple text boxes
'use the sample code below

Randomize
   Dim t1 As Integer
   t1 = Int(Rnd(1) * 9)
   Text2.Text = CStr(t1)
   Dim t2 As Integer
   t2 = Int(Rnd(1) * 9)
   Text3.Text = CStr(t2)
   Dim t3 As Integer
   t3 = Int(Rnd(1) * 9)
   Text4.Text = CStr(t3)
   Dim t5 As Integer
   t5 = Int(Rnd(1) * 9)
   Text5.Text = CStr(t5)
   Dim t6 As Integer
   t6 = Int(Rnd(1) * 9)
   Text6.Text = CStr(t6)
   Dim t7 As Integer
   t7 = Int(Rnd(1) * 9)
   Text7.Text = CStr(t7)
'If you want all these numbers to appear in another text box use 
'this code
Text8.Text = (Text1.Text) & (Text2.Text) & (Text3.Text) & (Text4.Text) & (Text5.Text) & (Text6.Text) & (Text7.Text)
End Sub

Download this snippet    Add to My Saved Code

Create random numbers when a button is pushed and display those numbers in a text box Comments

No comments have been posted about Create random numbers when a button is pushed and display those numbers in a text box. Why not be the first to post a comment about Create random numbers when a button is pushed and display those numbers in a text box.

Post your comment

Subject:
Message:
0/1000 characters