Reputation: 11
why does & not create a space between the two numbers being displayed?
'random generates lottery numbers
Dim Lotto As New Random
Dim intNum1 As Integer
Dim intNum2 As Integer
Dim intNum3 As Integer
Dim intNum4 As Integer
Dim intNum5 As Integer
Dim IntNum6 As Integer
Dim IntTotal As Integer
intNum1 = Lotto.Next(1, 54)
intNum2 = Lotto.Next(1, 54)
intNum3 = Lotto.Next(1, 54)
intNum4 = Lotto.Next(1, 54)
intNum5 = Lotto.Next(1, 54)
IntNum6 = Lotto.Next(1, 54)
'winning lotto numbers
IntTotal = intNum1 & intNum2 & intNum3
lblLottoNum.Text = IntTotal.ToString()
Upvotes: 0
Views: 120
Reputation: 27322
Have a look at String.Format. This allows you to format the string you want and is easy to read:
for example you could do this:
lblLottoNum.Text = String.Format("The numbers are: {0}, {1} and {2}", intNum1, intNum2, intNum3)
Upvotes: 1
Reputation: 10013
is this what you want?
lblLottoNum.Text = intNum1.ToString() & " " & intNum2.ToString() & " " & intNum3.ToString()
Upvotes: 0
Reputation: 34846
No need for the IntTotal
variable, instead just put spaces between the individual numbers themselves, like this:
lblLottoNum.Text = intNum1.ToString() & " " & intNum2.ToString() & _
" " & intNum3.ToString()
Upvotes: 1