VB 6 – Rnd() Function

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

Output: Rnd() Function

Output - Rnd() Function
Figure 1 – Output – Rnd() Function


Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.