inkedgfx
Well-known member
I have a lottery program I am working on... its almost complete but need one more thing done to it....
I have it saving the winning numbers drawn from the lottery... it saves to a txt doc then if the user clicks view numbers, a listbox is filled with the saved txt doc...the txt doc has numbers and letters in it..I would like to fill the listbox with just the numbers, so I then can generate a randome set of numbers from the numbers pulled from the txt doc...if that makes any sence at all.....also the numbers(5) will be an unknown array , I put 5 just so I could test it out....as the txt doc grows , so will the numbers array...not sure how to code that part either.......
here is what I have -
this is in a button click event
thank you for any help.
InkedGFX
I have it saving the winning numbers drawn from the lottery... it saves to a txt doc then if the user clicks view numbers, a listbox is filled with the saved txt doc...the txt doc has numbers and letters in it..I would like to fill the listbox with just the numbers, so I then can generate a randome set of numbers from the numbers pulled from the txt doc...if that makes any sence at all.....also the numbers(5) will be an unknown array , I put 5 just so I could test it out....as the txt doc grows , so will the numbers array...not sure how to code that part either.......
here is what I have -
this is in a button click event
Dim path As String = Application.StartupPath & "\lotteryNumbers\WinningNumbers.txt"
Dim ListtoSplit As String = path
Dim Index, numbers(5) As Integer
Dim stringSplit() As String = ListtoSplit.Split(",")
Dim i As Integer
Do While (ListNumbers.SelectedItems.Count > 0) ' clear the listbox before putting the numbers in
ListNumbers.Items.Clear()
Loop
For i = 0 To stringSplit.Length - 1 'find the numbers in the ListtoSplit variable
If stringSplit(i).Contains(",") Then
If Integer.TryParse(stringSplit(i + 1), numbers(Index)) Then
Index += 1
ListNumbers.Items.Add(numbers(0)) ' add each number to the listbox
If Index = 6 Then Exit For
End If
End If
Next
thank you for any help.
InkedGFX