0

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

'随机生成彩票号码

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

3 回答 3

1

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

lblLottoNum.Text = intNum1.ToString() & " " & intNum2.ToString() & _
    " " & intNum3.ToString()
于 2013-11-13T02:52:21.060 回答
1

看看String.Format。这使您可以格式化所需的字符串并且易于阅读:

例如你可以这样做:

lblLottoNum.Text = String.Format("The numbers are: {0}, {1} and {2}", intNum1, intNum2, intNum3)
于 2013-11-13T08:01:11.290 回答
0

这是你想要的吗?

lblLottoNum.Text = intNum1.ToString() & " " & intNum2.ToString() & " " & intNum3.ToString()
于 2013-11-13T02:51:44.443 回答