Link to home
Start Free TrialLog in
Avatar of hamda000
hamda000Flag for Canada

asked on

Random Numbers

I would like to generate multiple numbers between two values (Exemple: 2000 and 3000).
I wrote this program but it generate only one value at one click. I want to generate multiple integers in one click (2000, 2001, 2020, 2876...). Here is my code:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim r As Random = New Random
        MsgBox(r.Next(10, 15))
    End Sub
End Class

Any idea please?
Thanks.
Avatar of sofsol
sofsol
Flag of New Zealand image

I am assuming you want a character string that looks like "number, number, number"

Create a loop that runs "n" times according to how many random numbers you want.

Initialise a variable to store the result in and for each run through the loop, append a random number and, so long as n is less than the total of random numbers required, a comma and a space.

When the loop has finished, pass the variable back to the calling code.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hamda000

ASKER

Thanks. Now I have to work on the sorting.