如何在标签中显示多个数字

时间:2013-11-13 02:47:07

标签: vb.net random

为什么&不显示正在显示的两个数字之间的空格?

'随机生成彩票号

    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()

3 个答案:

答案 0 :(得分:1)

不需要IntTotal变量,只需在各个数字之间加上空格,如下所示:

lblLottoNum.Text = intNum1.ToString() & " " & intNum2.ToString() & _
    " " & intNum3.ToString()

答案 1 :(得分:1)

看看String.Format。这允许您格式化您想要的字符串并且易于阅读:

例如,你可以这样做:

lblLottoNum.Text = String.Format("The numbers are: {0}, {1} and {2}", intNum1, intNum2, intNum3)

答案 2 :(得分:0)

这就是你想要的吗?

lblLottoNum.Text = intNum1.ToString() & " " & intNum2.ToString() & " " & intNum3.ToString()