怎样做VB抽奖程序
Dim n As Integer
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
m:
n = Val(Text2.Text)
If n = 0 Then
n = InputBox("请输入需抽人数", "提示", 0)
Text2.Text = n
GoTo m
End If
Text1.Text = ""
Command2.Enabled = False
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Private Sub Form_Load()
For i = 0 To 4
Label1(i).FontSize = 60
Label1(i).FontBold = True
Label1(i) = "?"
Next i
End Sub
Private Sub Timer1_Timer()
Dim a(4) As Integer
For i = 0 To 4
a(i) = Int(Rnd * 10)
Label1(i) = a(i)
Next i
End Sub
Private Sub Timer2_Timer()
n = n - 1
If n >= 0 Then
Text1.Text = Text1.Text & Chr(13) & Chr(10) & Label1(0).Caption & Label1(1).Caption & Label1(2).Caption & Label1(3).Caption & Label1(4).Caption
DoEvents
Sleep 2000
Else
Timer2.Enabled = False
Timer1.Enabled = False
Command2.Enabled = True
For i = 0 To 4
Label1(i) = "?"
Next i
End If
End Sub