-
抽奖程序以PPT形式进行-实现名单抽取
资源介绍
需要调整ppt的 “工具--》宏--》安全性” 设置为低级。
代码如下:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim arrRM, F
'输入名单到: TextBox1 采用单个空格分隔,最前和最后一个数据后不要留空格(否则可能部分元素抽出为空)
'代码注释部分用于调试,或者你可以修改为其他用途,比如可以显示给用户观看。
Private Sub CommandButton1_Click()
If Me.CommandButton1.Caption = "停" Then
Me.CommandButton1.Caption = "开始"
Call CQ_do("stop")
Else
Me.CommandButton1.Caption = "停"
Call CQ_do("start")
End If
End Sub
Private Sub CQ_do(doTag)
Dim I
If doTag = "start" Then
arrRM = Split(Me.TextBox1, " ", -1, 1) '如果有需要你可以替换这里的空格,改为你需要的分隔符: 如个为英文分号 Split(Me.TextBox1, ";", -1, 1)
' TextBox3 = ""
' TextBox3.Visible = True
' TextBox4.Visible = True
' Me.TextBox4 = UBound(arrRM) & " " & arrRM(0) & " " & arrRM(UBound(arrRM))
F = 0
Do While True
Sleep 30
I = Int(((UBound(arrRM) + 1) * Rnd) + 0)
' TextBox3 = TextBox3 & "-" & I
TextBox2.Text = arrRM(I)
If F = 1 Then Exit Do
DoEvents
Loop
Else
F = 1
End If
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub TextBox2_Change()
End Sub