怎样做VB抽奖程序
Dim n As IntegerPrivate Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private Sub Command1_Click()EndEnd SubPrivate Sub Command2_Click()m:n = Val(Text2.Text)If n = 0 Then n = InputBox("请输入需抽人数", "提示", 0) Text2.Text = n GoTo mEnd IfText1.Text = ""Command2.Enabled = FalseTimer1.Enabled = TrueTimer2.Enabled = TrueEnd SubPrivate Sub Form_Load()For i = 0 To 4 Label1(i).FontSize = 60 Label1(i).FontBold = True Label1(i) = "?"Next iEnd SubPrivate Sub Timer1_Timer()Dim a(4) As IntegerFor i = 0 To 4 a(i) = Int(Rnd * 10) Label1(i) = a(i)Next iEnd SubPrivate Sub Timer2_Timer()n = n - 1If n >= 0 ThenText1.Text = Text1.Text & Chr(13) & Chr(10) & Label1(0).Caption & Label1(1).Caption & Label1(2).Caption & Label1(3).Caption & Label1(4).CaptionDoEventsSleep 2000ElseTimer2.Enabled = FalseTimer1.Enabled = FalseCommand2.Enabled = TrueFor i = 0 To 4 Label1(i) = "?"Next iEnd IfEnd Sub
vb抽奖程序
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Timer1.Enabled = True
Command1.Caption = "停止"
Else
Command1.Caption = "开始"
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "开始"
Timer1.Interval = 50
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Static a
a = a + 1
Label1 = a
If a = 10 Then a = 0
End Sub