0-9数字里选3个数字
如题 选3个就是C(10,3) 不要按照顺序的那种。。。120组的。。。如何用VB编出来
Private Sub cmdCommand1_Click()
Dim num1 As Integer, num2 As Integer, num3 As Integer
num1 = Rnd * 9
num2 = Rnd * 9
Do While num2 = num1
num2 = Rnd * 9
Loop
num3 = Rnd * 9
Do While num3 = num1 Or num3 = num2
num3 = Rnd * 9
Loop
Debug.Print num1 & " " & num2 & " " & num3
End Sub
试试 看OK不...Dim num1 As Integer, num2 As Integer, num3 As Integer
num1 = Rnd * 9
num2 = Rnd * 9
Do While num2 = num1
num2 = Rnd * 9
Loop
num3 = Rnd * 9
Do While num3 = num1 Or num3 = num2
num3 = Rnd * 9
Loop
Debug.Print num1 & " " & num2 & " " & num3
End Sub