VB抽签程序代码

VB抽签程序代码,第1张

Dim 数组()

Dim 计数

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

数组 = {"李欢", "龚丽", "谭显亮", "王涛", "徐荣辉", "刘烨", "郑权恒", "廖伟笑迅吵", "郭威", "李襑"}

计数 = 数组.Count

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim 随机 = New Random().Next(数组碰侍.Count)

Do

If 数组(随机) <>"" Then

计数 -= 1

Me.Text = 数组(随机) &计数

数组(随机) = ""昌闭

Exit Do

Else

随机 = New Random().Next(数组.Count)

End If

Loop While (计数 >1)

End Sub

Public j As Integer

Dim A() As String

Dim tem As String

Private Sub CMD1_Click() '注意这里如果没有exit sub,责会出现captio不会变的,其实已经变过了

If CMD1.Caption = "开始" Then

CMD1.Caption = "停止肆槐"

Timer1.Enabled = True

Exit Sub

End If

If CMD1.Caption = "停止" Then

CMD1.Caption = "开始"

Timer1.Enabled = False

If tem <> "" Then

Text1.Text = tem

End If

End If

End Sub

Private Sub CMD2_Click()

Frame1.Visible 裂衫友= True

Text2.Visible = True

CMD3.Visible = True

CMD4.Visible = True

End Sub

Private Sub CMD3_Click()

Text2.Visible = False

CMD3.Visible = False

CMD4.Visible = False

tem = Text2.Text

End Sub

Private Sub CMD4_Click()

Text2.Text = ""

Text2.Visible = False

CMD3.Visible = False

CMD4.Visible = False

End Sub

Private Sub form_load()

Frame1.Visible = False

Text2.Visible = False

CMD3.Visible = False

CMD4.Visible = False

Timer1.Enabled = False

Timer1.Interval = 300

Open "C:\Documents and Settings\Administrator\桌塌衫面\新建 文本文档.txt" For Input As 1

Do Until EOF(1)

ReDim Preserve A(0 To I)

Input #1, A(I)

I = I + 1

Loop

Close #1

End Sub

Private Sub Timer1_Timer()

Text1.Text = A(j)

j = j + 1

If j = UBound(A) Then

j = 0

End If

End Sub

已经运行通过,不过事先你得在桌面建立一个文本文件,用来存储数据,呵呵

语言实现此程序。

以下是VB编程语言的实现示例:

'定义变量,存储每个奖项的人数

Dim firstPrize As Integer = 3

Dim secondPrize As Integer = 5

Dim thirdPrize As Integer = 12

Dim souvenirPrize As Integer = 10

'定义变量,存储抽奖结果

Dim firstPrizeList As New List(Of Integer)

Dim secondPrizeList As New List(Of Integer)

Dim thirdPrizeList As New List(Of Integer)

Dim souvenirPrizeList As New List(Of Integer)

'定义变量,存储编号滚动的起始编号

Dim currentNum As Integer = 1

'循环抽取各种奖项

For i As Integer = 1 To firstPrize

'抽取一等奖,并将编号添加到一等奖名单

firstPrizeList.Add(currentNum)

currentNum += 1

Next

For i As Integer = 1 To secondPrize

'抽取二等奖,并将编号添加到二等奖名单中

secondPrizeList.Add(currentNum)

currentNum += 1

Next

For i As Integer = 1 To thirdPrize

'抽取三等奖,并将编洞派号添加到三等奖名单中

thirdPrizeList.Add(currentNum)

currentNum += 1

Next

For i As Integer = 1 To souvenirPrize

'抽取纪念奖,并将编纳档贺号添加到纪念奖名单中

souvenirPrizeList.Add(currentNum)

currentNum += 1

Next

'输出抽奖结果

Console.WriteLine("一等奖名单:" &String.Join(",", firstPrizeList))

Console.WriteLine("二等奖名单:" &String.Join("蠢凯,", secondPrizeList))

Console.WriteLine("三等奖名单:" &String.Join(",", thirdPrizeList))

Console.WriteLine("纪念奖名单:" &String.Join(",", souvenirPrizeList))


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12235119.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-22
下一篇2023-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存