本人新手,各位能解释下每句的意思吗
Option ExplicitDim xm As String
Dim index As Integer
Dim k%
Dim RStr As String
Dim RStr1(0 To 99) As String
Dim RStr2(0 To 99) As String
'Private Sub Command1_Click()
''定义一个数组来存储人名
'
'Dim i, j, k '给要滚动的数给赋值'实际使用应该是 RStr(0)="张三" :RStr(1)="李四" 之类
'
''判断按钮标题
'If Command1.Caption = "按编号抽奖" Then
''改变标题
' Command1.Caption = "结束"
''开始滚动显示
'Do While 1
''检测到按钮标题变回开始,即点击结束后,退出死循环并赋值
' If Command1.Caption = "按编号抽奖" Then
' Label1.Caption = "获奖人:" & Text1.Text
'Exit Do
' End If
''转让控制权,即使在循环中也可以点击按钮
'DoEvents
''初始化随机数生成器。
'Randomize
''随机生成一个0到9的数字
'k = Int(Rnd * (10 - index))
''写入text1
'Text1.Text = RStr1(k) & "号"
'
''刷新text1
'Text1.Refresh
'
'Loop
'List2.AddItem List1.List(k)
'List1.RemoveItem (k)
'index = index + 1
'Else
''改变标题
'Command1.Caption = "按编号抽奖"
''MsgBox "恭喜" & Text1.Text & "获奖!", vbOKOnly, "恭喜获奖!"
'
'Exit Sub
'End If
''End If
'
'End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
'定义一个数组来存储人名
Dim i, j '给要滚动的数给赋值'实际使用应该是 RStr(0)="张三" :RStr(1)="李四" 之类
'判断按钮标题
If Command3.Caption = "开始抽奖" Then
'改变标题
Command3.Caption = "结束"
'开始滚动显示
Do While 1
'检测到按钮标题变回开始,即点击结束后,退出死循环并赋值
If Command3.Caption = "开始抽奖" Then
Label1.Caption = "获奖人:" & Text1.Text
Exit Do
End If
'转让控制权,即使在循环中也可以点击按钮
DoEvents
'初始化随机数生成器。
Randomize
'随机生成一个0到9的数字
i = Int(Rnd * (k - index))
'写入text1
Text1.Text = List1.List(i)
'刷新text1
Text1.Refresh
Loop
If index < k Then
List2.AddItem List1.List(i)
List1.RemoveItem (i)
index = index + 1
Else
MsgBox "已没有抽奖人员!"
End If
Else
'改变标题
Command3.Caption = "开始抽奖"
'MsgBox "恭喜" & Text1.Text & "获奖!", vbOKOnly, "恭喜获奖!"
Exit Sub
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim j As Integer
Adodc1.ConnectionString = "provider=microsoft.jet.OLEDB.4.0;Data source=" & App.Path & "\user.mdb;persist security Info=false"
Adodc1.RecordSource = "select * from usepass "
Adodc1.Refresh
'Command1.Caption = "按编号抽奖"
Command3.Caption = "开始抽奖"
Label1.Caption = "获奖人:"
Text1.Text = "请开始抽奖...."
'Open App.Path & "\抽奖名单.txt" For Input As #1
' While Not EOF(1)
' Line Input #1, RStr
Do Until Adodc1.Recordset.EOF
List1.AddItem Adodc1.Recordset(0) & " " & Adodc1.Recordset(1)
Adodc1.Recordset.MoveNext
Loop
' Wend
'Close #1
k = Adodc1.Recordset.RecordCount
For i = 1 To List1.ListCount
If i < 10 Then
RStr1(i) = "0" & i
Else
RStr1(i) = i
End If
Next i
End Sub