主题:一个判断两个数是否相等的问题!
Private Sub Command1_Click()
Dim a1 As Single
Dim i As Single
Dim b As String
Dim b1 As String
Dim b2 As String
Dim x As String
'初始化
b = ""
b1 = ""
b2 = ""
For i = 0 To 5 '循环6次,每次生成一个随即数
11:
a1 = Int((33 * Rnd) + 1)
b1 = a1
If StrComp(b1, b2, 0) = 0 Then '判断随机数不能相同
GoTo 11
Else
x = b1
End If
b2 = a1
Me.a(i).Text = x
Next
End Sub
我想生成6个随机数,已经实现了,另一个要求是这6个数不能重复,现在总是出现两个数重复,请大家帮忙看看为什么无法判断b1,b2是否相同,谢谢啊
Dim a1 As Single
Dim i As Single
Dim b As String
Dim b1 As String
Dim b2 As String
Dim x As String
'初始化
b = ""
b1 = ""
b2 = ""
For i = 0 To 5 '循环6次,每次生成一个随即数
11:
a1 = Int((33 * Rnd) + 1)
b1 = a1
If StrComp(b1, b2, 0) = 0 Then '判断随机数不能相同
GoTo 11
Else
x = b1
End If
b2 = a1
Me.a(i).Text = x
Next
End Sub
我想生成6个随机数,已经实现了,另一个要求是这6个数不能重复,现在总是出现两个数重复,请大家帮忙看看为什么无法判断b1,b2是否相同,谢谢啊