Visual Basic Lottery number generator in 2d array

  • Thread starter Thread starter Jonathan.12
  • Start date Start date
J

Jonathan.12

Guest
Hello,

I'm building a Lottery number generator with Visual Basic (XAML). I want a random number generator with only unique numbers. The random numbers have to be stored in a Text Box (in my case I called it LotteryCard).

I have the next code:

Dim Lottery(A, B) As Integer
Dim Random As New System.Random()
Dim C, R As Integer
Dim LotteryNumbers As String

For C = 0 To 2
For R = 0 To 2
Lottery(C, R) = Random.Next(0, 100)
LotteryNumbers += Lottery(C, R) & " , "
Next R
LotteryCard.text = LotteryNumbers
Next C

When I run my code I only see a line with numbers in my LotteryCard.text Textbox with duplicates like:

22, 33, 22, 33, 44, 55, 60, 6, 4, 2, 3, 4, 5 etc.

I have three questions:

1. Is there a way to generate unique random numbers?

2. Is there a way to order my numbers in a kind of range (first row: only 0 to 9, second row 10 to 19, third row 20 to 29).

3. Is there a way show my numbers in the Textbox with 3 rows and 3 columns like:

1 6 7 2

12 15 18 19

20 23 27 29

Thanks in advance,

Jonathan

Continue reading...
 

Similar threads

R
Replies
0
Views
333
redraider29003
R
S
Replies
0
Views
150
Ste Wilko
S
G
Replies
0
Views
107
GraemeFBaillie
G
Back
Top