VB抽奖程序,求高手给个完整的程序,按人名抽,十分感谢
A:人名不可重复抽奖B:抽奖结束有提示
C:大约130人抽奖
十分急,高手请给小弟个程序,十分感谢,十分感谢.
.......... '给你个6个人的:
'注意Text2的Multiline设为True又写了一个:
Dim j As Integer
Dim a() As String
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Dim b()
Dim i, k As Integer
Timer1.Enabled = False
For i = 0 To UBound(a)
If Text1.Text = a(i) Then
Else
ReDim Preserve b(k)
b(k) = a(i)
k = k + 1
End If
Next
ReDim a(j - 1)
For i = 0 To UBound(b)
a(i) = b(i)
Next
j = j - 1
Text2.Text = Text2.Text & Text1.Text & vbCrLf
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Text1.Text = ""
Command1.Caption = "开始"
Command2.Caption = "停止"
Command3.Caption = "退出"
Timer1.Interval = 500
j = 5
ReDim a(5)
a(0) = "李 林"
a(1) = "胡广涛"
a(2) = "李慧茹"
a(3) = "辛文鹏"
a(4) = "薄 奔"
a(5) = "赵和香"
Text2.Text = "已抽出名单" & vbCrLf
End Sub
Private Sub Timer1_Timer()
Text1.Text = ""
If j = 1 Then Timer1.Enabled = False: Exit Sub
i = Int(j * Rnd)
Text1.Text = a(i)
End Sub
Private Sub Form_Load()这个对你有用http://blog.csdn.net/grenet/archive/2009/10/05/4634053.aspx 我也看看去 都是牛人 我想有点参考作用:愿意保存
Dim a
Dim b(4) As Integer
Dim i, j, k
Dim bl As Boolean
Dim s As String
a = Array("赵一", "钱礼", "孙亮", "李军", "周兵", "吴二", "郑新", "王大", "冯三", "陈九", "褚明", "魏连", "何伟", "吕仁", "施明", "张三", "刘杰", "肖娟", "黄星", "朱敏", "叶颖", "罗钢", "程昊", "夏武", "陶兴")
'从25人中抽5个奖,若要130人,名单自己在a中添加
Randomize
k = Int(UBound(a) * Rnd)
b(j) = k '抽第1个奖
Do
bl = False
Randomize
k = Int(UBound(a) * Rnd)
For i = 0 To 4
If k = b(i) Then
bl = True
Exit For
End If
Next
If bl = False Then
j = j + 1
b(j) = k
End If
Loop Until j = 4
For i = 0 To 4
s = s & a(b(i)) & vbCrLf
Next
MsgBox "获奖名单为:" & vbCrLf & s
End Sub
VB code
'注意Text2的Multiline设为True
Dim j As Integer
Dim a() As String
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Dim b()
Dim i, k As In……
[/Quote] 同样例证,参考一下吧:谢谢!
VB code
Private Sub Form_Load()
Dim a
Dim b(4) As Integer
Dim i, j, k
Dim bl As Boolean
Dim s As String
a = Array("赵一", "钱礼", "孙亮", "李军", "周兵", "吴二", "郑新", "王大", "冯三", "陈九", "褚明", "魏连……
[/Quote] 楼主很艰难.真的很艰难啊。有固定人数还不简单,看大家把随机数弄的。
数组人名。然后随机选个。存起。界面数在跑。然后再选得时候。吧结果和已存名比对。存在就再随机嘛。。。
补充:VB , 资源