The VB6 random number function is Rnd()
. It generates a random number. In the following program we will use this function to generate a random number.
The Rnd() function generates a number between 0 to 1 which is a double value. However, you may increase the value of random number by multiplying it with some integer value.
For example.
result = Rnd() * 20 // will generate number less than 20
Program Code: Rnd() Function
Private Sub Command1_Click()
Dim result As Double
result = Rnd()
Text1.Text = Str(result)
End Sub