关于按键精灵的,在10内随机取5个不同的数,如果有1就按a建,如果有2就按b建……怎么写

1个回答

  • 包括0和10吗,我下面的代码没有0和10的。代码我不解释了,你自己理解。

    Dim Number(4)

    For i = 0 To 4

    Number(i) = 0

    Next

    n = 0

    While n < 5

    Randomize

    m = Int(9 * Rnd + 1)

    For i = 0 To n

    If m = Number(i) Then

    Exit For

    End If

    Next

    If i >= n Then

    Number(n) = m

    n = n + 1

    End If

    Wend

    //MessageBox Number(0) & "," & Number(1) & "," & Number(2) & "," & Number(3) & "," & Number(4)

    //上面MessageBox后面的是一行的

    For i = 0 To 4

    KeyPress 64 + Number(i), 1

    Delay 200

    Next