vb.net 多次滚动抽奖的程序代码抽奖软件vb.net代码我用多线程写的,抽奖软件vb.net代码你可以参考下 。
系统界面图如下:(注:重置功能为清除已经中奖号码,回归1-100都可以中奖状态 。)
代码:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
System.Threading.Thread g_Thread = null;
Listint g_list = new Listint();
int g_Num = 0;
delegate void g_delegate();
/// summary
/// 开始
/// /summary
/// param name="sender"/param
/// param name="e"/param
private void button2_Click(object sender, EventArgs e)
{
if(g_list.Count==100)
{
MessageBox.Show("所有数字已使用,请重置!");
return;
}
button3.Enabled = true;
Random r = new Random();
g_delegate dele= ChangeTxt;
g_Thread = new System.Threading.Thread(() =
{
while(this.IsDisposed==false)
{
g_Num = r.Next(1, 100);
if(g_list.Contains(g_Num))
{
g_Num =1;
}
while(g_list.Contains(g_Num))
{
g_Num;
}
this.Invoke(dele);
System.Threading.Thread.Sleep(50);
}
});
g_Thread.Start();
}
void ChangeTxt()
{
label2.Text = g_Num.ToString();
}
/// summary
/// 停止
/// /summary
/// param name="sender"/param
【抽奖软件vb.net代码 vb抽奖小程序】/// param name="e"/param
private void button3_Click(object sender, EventArgs e)
{
//if(g_Thread.ThreadState==System.Threading.ThreadState.Running)
{
g_Thread.Abort();
g_list.Add(Convert.ToInt32(label2.Text));
}
button3.Enabled = false;
}
/// summary
/// 重置
/// /summary
/// param name="sender"/param
/// param name="e"/param
private void button1_Click(object sender, EventArgs e)
{
g_list.Clear();
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
System.Environment.Exit(0);
}
}
VB中可用的抽奖程序的代码Dim a(1 To 100) As String
Dim i As Integer, x As Integer
Const n = 3 'n抽奖软件vb.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) = "庞麦郎"
a(3) = "非主流"
For i = 1 To n
List1.AddItem a(i)
Next
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
x = Rnd() * n1 '产生一个[1抽奖软件vb.net代码,n]中抽奖软件vb.net代码的随机整数并存入变量x中
Label2.Caption = a(x) '在标签Label2中显示下标变量a(x)的值(第x个人的姓名)
End Sub
抽奖程序(用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
=
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.net代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vb抽奖小程序、抽奖软件vb.net代码的信息别忘了在本站进行查找喔 。
推荐阅读
- 电商如何加强内部管理,电商企业的内部控制
- 计算机毕业设计程序报错,计算机系毕业设计源码
- 安装系统怎么区分u盘,u盘安装系统怎么分区教程
- mysql控制台怎么建表 mysql控制台命令大全
- 有线新媒体盒子如何修饰,媒体盒安装
- 经营游戏450924,经营游戏一层一层的开店
- word字的间距如何调整,word字间距怎么调整一致
- go语言困境 go语言难吗
- 女性做sap的来说说,女性做sap都包括什么项目