Many questions in VB are regarding random numbers. In this tutorial I will try and explain the basic ideas regarding random numbers so it'll be easier for you to create your applications.
Intro - The Rnd Function
The first thing you need to know is the function that generates a random number. The function is called : Rnd. Here is how you use it :
1) Open a new project in VB.
2) In the load event of your form add the following code :
VB Code:
Private Sub Form_Load() Dim i As Integer For i = 1 To 10 Debug.Print Rnd Next End Sub
3) Run the project. In the Immediate window you will notice that 10 numbers have been printed.




Reply With Quote