1条回答 默认 最新
- threenewbee 2019-07-09 10:46关注
使用方法,编辑names文件,每个名字1行
注意,需要抽取的人,名字后面加上一个空格
不希望抽取的人,不要加
则程序滚动的时候,所有人都参与滚动,停止的时候,有空格的才会出来Option Explicit Private isRunning As Boolean Dim names() As String Private Sub CommandButton1_Click() CommandButton1.Enabled = False Dim filecontent As String Open "names.txt" For Binary As #1 filecontent = Input(LOF(1), #1) Close #1 names = Split(filecontent, vbCrLf) Randomize isRunning = True While isRunning TextBox1.Text = RndName(False) DoEvents Wend TextBox1.Text = RndName(True) If TextBox1.Text = "" Then CommandButton1.Enabled = True: Exit Sub If Me.Application.ActivePresentation.Slides(2).Shapes(6).TextFrame.TextRange.Text <> "" Then Me.Application.ActivePresentation.Slides(2).Shapes(6).TextFrame.TextRange.Text = Me.Application.ActivePresentation.Slides(2).Shapes(6).TextFrame.TextRange.Text & "," Me.Application.ActivePresentation.Slides(2).Shapes(6).TextFrame.TextRange.Text = Me.Application.ActivePresentation.Slides(2).Shapes(6).TextFrame.TextRange.Text & TextBox1.Text CommandButton1.Enabled = True End Sub Private Function RndName(isSpec As Boolean) As String Dim cnt As Long cnt = 1 Dim idx As Long Do cnt = cnt + 1 If cnt > 99999 Then RndName = "" Exit Function End If idx = Int(Rnd * (UBound(names) - LBound(names) + 1)) + LBound(names) If Not IsExist(names(idx)) Then If isSpec Then If (names(idx) <> Trim(names(idx))) Then RndName = Trim(names(idx)) Exit Do End If Else RndName = Trim(names(idx)) Exit Do End If End If Loop End Function Private Function IsExist(name As String) As Boolean Dim arr() As String arr = Split(Me.Application.ActivePresentation.Slides(2).Shapes(6).TextFrame.TextRange.Text, ",") Dim i As Long For i = LBound(arr) To UBound(arr) If Trim(name) = Trim(arr(i)) Then IsExist = True Exit Function End If Next IsExist = False End Function Private Sub CommandButton2_Click() isRunning = False End Sub
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 1
悬赏问题
- ¥15 素材场景中光线烘焙后灯光失效
- ¥15 请教一下各位,为什么我这个没有实现模拟点击
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 ubuntu子系统密码忘记
- ¥15 保护模式-系统加载-段寄存器