用vb 做个双色球摇奖工具
来源:百度知道 编辑:UC知道 时间:2024/05/20 12:28:31
每个红球是1~33 蓝球1~16 红球不重复 你们说的窗体是什么样式的?? 7个标签 两个按钮
Private Sub Command1_Click()
Randomize
Cls
Dim a
a = GetRndNotRepeat(1, 33, 6)
Print "红球";
For i = 0 To UBound(a)
Print a(i);
Next
Print " 蓝球"; Int(Rnd * (17) + 1)
End Sub
Public Function GetRndNotRepeat(ByVal NumMin As Integer, ByVal NumMax As Integer, ByVal n As Integer)
If n > NumMax - NumMin + 1 Then Exit Function
Dim arr()
ReDim arr(n - 1)
Dim b() As Boolean
ReDim b(NumMax - NumMin)
Dim x As Integer, y As Integer
Randomize
For i = 0 To n - 1
Do
x = Int(Rnd * (NumMax - NumMin + 1)) + NumMin
y = x - NumMin
Loop While b(y)
b(y) = True
arr(i) = x
Next i
GetRndNotRepeat = arr
End Function
Private Sub Command1_Click()
Print rndNum(1, 33, 6)
Print rndNum(1, 16, 1)
End Sub
需要窗体的,光代码有什么用.