300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > vba随机抽取人名不重复_用vb编写个随机滚动抽取人名的抽奖系统 怎么样做到不重复并添

vba随机抽取人名不重复_用vb编写个随机滚动抽取人名的抽奖系统 怎么样做到不重复并添

时间:2022-06-12 10:11:23

相关推荐

vba随机抽取人名不重复_用vb编写个随机滚动抽取人名的抽奖系统 怎么样做到不重复并添

在页面中加一个listbox,一个textbox,一个commandbutton

代码如下:

Dim a() As String, temp As String

Dim i As Integer, award As Integer

Dim Clickbutton As Boolean

Private Sub CommandButton1_Click()

If Clickbutton True Then

Open "E:\2.txt" For Input As #1‘把你的人员名单存在记事本中,一行一个人,路径你可以改一下

Do While Not EOF(1)

Line Input #1, temp

If temp "" Then

i = i + 1

ReDim Preserve a(i)

a(i) = temp

Debug.Print temp

End If

Loop

Close (1)

ListBox1.Clear

TextBox1.Text = ""

Clickbutton = True

End If

i = 0

If UBound(a) = 0 Then Exit Sub

Do

CommandButton1.Enabled = False

i = i + 1

DoEvents

award = Int(UBound(a) * Rnd + 1)

TextBox1.Text = a(award)

If i = 50 Then Exit Do

Loop

ListBox1.AddItem ListBox1.ListCount + 1 & ":" & TextBox1.Text

TextBox1.Text = ""

CommandButton1.Enabled = True

If award = UBound(a) Then

ReDim Preserve a(award - 1)

Debug.Print UBound(a)

Exit Sub

End If

For i = award To UBound(a) - 1

a(i) = a(i + 1)

Next

ReDim Preserve a(i - 1)

Debug.Print UBound(a)

End sub

你也可以给我个邮箱,我把做好的PPT给你,别忘了告诉我你用的PPT是的还是的

vba随机抽取人名不重复_用vb编写个随机滚动抽取人名的抽奖系统 怎么样做到不重复并添加一个记录显示已抽到的人名...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。