vb.net抽奖程序代码 vba抽奖程序

抽奖程序(用vb编写)在窗体上添加一个command1,一个timer1,label1(0~5)
控件数组(添加一个label1,然后再复制5个,共6个 , 用来显示数字),代码如下:
Private
Sub
Command1_Click()
If
Command1.Caption
=
"抽奖"
Then
Command1.Caption
=
"停止"
Timer1.Enabled
=
True
Else
Timer1.Enabled
=
False
Command1.Caption
=
"抽奖"
End
If
End
Sub
Private
Sub
Form_Load()
Command1.Caption
=
"抽奖"
Timer1.Interval
=
50
Timer1.Enabled
=
False
End
Sub
Private
Sub
Timer1_Timer()
Randomize
For
i
=
To
5
Label1(i)
=
Int(10
*
Rnd)
Select
Case
Label1(i).Caption
Case
Label1(i).BackColor
=
RGB(0,
0,
0)
Label1(i).ForeColor
=
RGB(255,
255,
255)
Case
1
Label1(i).BackColor
=
RGB(128,
42,
42)
Label1(i).ForeColor
=
RGB(127,
213,
213)
Case
2
Label1(i).BackColor
=
RGB(255,
0,
0)
Label1(i).ForeColor
=
RGB(0,
255,
255)
Case
3
Label1(i).BackColor
=
RGB(255,
97,
0)
Label1(i).ForeColor
=
RGB(0,
158,
255)
Case
4
Label1(i).BackColor
=
RGB(255,
255,
0)
Label1(i).ForeColor
=
RGB(0,
0,
255)
Case
5
Label1(i).BackColor
=
RGB(0,
255,
0)
Label1(i).ForeColor
=
RGB(255,
0,
255)
Case
6
Label1(i).BackColor
=
RGB(0,
0,
255)
Label1(i).ForeColor
=
RGB(255,
0,
0)
Case
7
Label1(i).BackColor
=
【vb.net抽奖程序代码 vba抽奖程序】RGB(160,
32,
240)
Label1(i).ForeColor
=
RGB(95,
223,
15)
Case
8
Label1(i).BackColor
=
RGB(192,
192,
192)
Label1(i).ForeColor
=
RGB(63,
63,
63)
Case
9
Label1(i).BackColor
=
RGB(255,
255,
255)
Label1(i).ForeColor
=
RGB(0,
0,
0)
End
Select
Next
End
Sub
请教vb源代码 , 抽奖程序,从100个人中抽取三等奖3个,二等奖2个 , 一等奖1个,每次抽奖不重复 。Public Sub Main()
Dim allLeft As New List(Of Integer)()
For i As Integer = 0 To 99
allLeft.Add(i + 1)
Next
Dim r As New Random()
Dim [next] As Integer
Dim level As String
For i As Integer = 0 To 5
[next] = r.[Next]() Mod allLeft.Count
If i3 Then
level = "Third"
ElseIf i5 Then
level = "Second"
Else
level = "First"
End If
Console.WriteLine(level" level prize is: "allLeft([next]).ToString())
allLeft.RemoveAt([next])
Next
End Sub
VB中可用的抽奖程序的代码Dim a(1 To 100) As String
Dim i As Integer, x As Integer
Const n = 3 'nvb.net抽奖程序代码的值可根据实际需要赋予不同vb.net抽奖程序代码的变量
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Randomize '初始化随机数生成器
a(1) = "富士康" '以此将n个人vb.net抽奖程序代码的姓名保存在数组a中
a(2) = "庞麦郎"

推荐阅读