Hello All,
I'm trying to create a lottery program where I load a group of customer names into a listbox from a file and then I want to randomly choose a name from the listbox and display it in a label. I was able to get it using:
Label1.Text = lstcustomers.Items(Int(Rnd() * pintcount))
but that generates the same names when you reload the file and begin the random choosing. So the first name to come up is always the same once I exit and reload the program and the file.
I then found a Randomobject Function:
Public Function GetRandomNumber(ByVal Low As Integer, ByVal High As Integer) As Integer
' Returns a random number,
' between the optional Low and High parameters
Return objRandom.Next(Low, High + 1)
End Function
And I can get that to generate in the label fine as numbers.
My question is how do I link those random numbers to the items listed in the listbox?
Any help would be greatly appreciated.
I'm trying to create a lottery program where I load a group of customer names into a listbox from a file and then I want to randomly choose a name from the listbox and display it in a label. I was able to get it using:
Label1.Text = lstcustomers.Items(Int(Rnd() * pintcount))
but that generates the same names when you reload the file and begin the random choosing. So the first name to come up is always the same once I exit and reload the program and the file.
I then found a Randomobject Function:
Public Function GetRandomNumber(ByVal Low As Integer, ByVal High As Integer) As Integer
' Returns a random number,
' between the optional Low and High parameters
Return objRandom.Next(Low, High + 1)
End Function
And I can get that to generate in the label fine as numbers.
My question is how do I link those random numbers to the items listed in the listbox?
Any help would be greatly appreciated.