求大神帮我解释一段vb代码,感激不尽,是彩票选号小助手的 10
求大神帮我解释一段vb代码,感激不尽,是彩票选号小助手的PrivateSubcommand1_Click()N=-1Fori=0To4N=N+1Ifoption1(i)....
求大神帮我解释一段vb代码,感激不尽,是彩票选号小助手的Private Sub command1_Click()N = -1For i = 0 To 4 N = N + 1 If option1(i).Value = True Then Exit For End IfNext iDim a(1 To 7) As IntegerFor i = 0 To NFor j = 1 To 7Randomizea(j) = Int(Rnd * 35 + 1)Next jFor k = 1 To 7For m = k + 1 To 7If a(k) = a(m) Then v = Int(Rnd * 35 + 1) Do While v = a(1) Or v = a(2) Or v = a(3) Or v = a(4) Or v = a(5) Or v = a(6) Or v = a(7) v = Int(Rnd * 35 + 1) Loop a(k) = vEnd IfNext mNext kFor k = 1 To 7For m = k + 1 To 7If a(k) > a(m) Then X = a(k) a(k) = a(m) a(m) = XEnd IfNext mNext kText1(i) = Format(a(1), "00")Text2(i) = Format(a(2), "00")Text3(i) = Format(a(3), "00")Text4(i) = Format(a(4), "00")Text5(i) = Format(a(5), "00")Text6(i) = Format(a(6), "00")Text7(i) = Format(a(7), "00")Next iEnd Sub
展开
2个回答
展开全部
Private Sub command1_Click()
N = -1
For i = 0 To 4
N = N + 1
If option1(i).Value = True Then Exit For
End If
Next i
Dim a(1 To 7) As Integer
For i = 0 To N
For j = 1 To 7
Randomizea(j) = Int(Rnd * 35 + 1)'随机生成号码
Next j
For k = 1 To 7
For m = k + 1 To 7
If a(k) = a(m) Then v = Int(Rnd * 35 + 1)
Do While v = a(1) Or v = a(2) Or v = a(3) Or v = a(4) Or v = a(5) Or v = a(6) Or v = a(7)
v = Int(Rnd * 35 + 1)
Loop
a(k) = v'发现重复的号码,重新生成
End If
Next m
Next k
For k = 1 To 7
For m = k + 1 To 7
If a(k) > a(m) Then
X = a(k)
a(k) = a(m)
a(m) = X
End If
Next m
Next k
Text1(i) = Format(a(1), "00")
Text2(i) = Format(a(2), "00")
Text3(i) = Format(a(3), "00")
Text4(i) = Format(a(4), "00")
Text5(i) = Format(a(5), "00")
Text6(i) = Format(a(6), "00")
Text7(i) = Format(a(7), "00")
Next i'设置输出格式
End Sub
追问
能帮我解释下每句的意思吗
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询