Dim a(1 To 100) As String
Dim i As Integer, x As Integer
Const n = 3 'n的值可根据实际需要赋予不同的变量
Private Sub Command1_Click()
Timer1Enabled = True
End Sub
Private Sub Command2_Click()
Timer1Enabled = False
End Sub
Private Sub Form_Load()
Randomize '初始化随机数生成器
a(1) = "富士康" '以此将n个人的姓名保存在数组a中
a(2) = "庞麦郎"
a(3) = "非主流"
For i = 1 To n
List1AddItem a(i)
Next
Timer1Enabled = False
End Sub
Private Sub Timer1_Timer()
x = Rnd() n + 1 '产生一个[1,n]中的随机整数并存入变量x中
Label2Caption = a(x) '在标签Label2中显示下标变量a(x)的值(第x个人的姓名)
End Sub
Option Base 1
Dim xm ,xmOk 'xmOk用来保存对应的姓名有没有被选中
Dim i As Integer
Private Sub form_load()
xm = Array("张三", "李四", "王麻子", "二娃", "大妞")
xmOk=Array(0,0,0,0,0)
End Sub
Private Sub Command1_Click() '命令按钮1的单击事件
Timer1Enabled = True
End Sub
Private Sub command2_click()
Timer1Enabled = flase
End Sub
Private Sub timer1_timer()
i = Int(Rnd 5) + 1
if xmOk(i)=1 then
Label1Caption = xm(i)
else
xmOk(i)=1
end if
End Sub
Private Sub Command1_Click()
Text3(0) = ""
Text3(1) = ""
Text3(2) = ""
Text3(3) = ""
Text3(4) = ""
Text3(5) = ""
Text3(6) = ""
Text3(7) = ""
Text3(8) = ""
Randomize
For a = 0 To 2
For n = 10 To 130
x = Int(Rnd n) - 30 '产生随机整数
Next n
For b = -15 To 30
y = x - b
Next b
If 80 < x Or 0 < x < 20 Or -20 < x < 0 Or x < -80 Or x = 0 Then
Text1(a) = ""
End If
If 20 < x < 80 Or -80 < x < -20 Then
Text1(a) = y 10 ^ -2
End If
If Text2(0) = "" Then
Text2(0) = 0
Text2(1) = 0
Text2(2) = 0
Text1(a) = 0
End If
Next a
For m = 3 To 5
For n = 10 To 130
x = Int(Rnd n) - 30 '产生随机整数
Next n
For b = -15 To 30
y = x - b
Next b
If 80 < x Or 0 < x < 20 Or -20 < x < 0 Or x < -80 Or x = 0 Then
Text1(m) = ""
End If
If Text2(3) = "" Then
Text2(3) = 0
Text2(4) = 0
Text2(5) = 0
Text1(m) = 0
End If
If 20 < x < 80 Or -80 < x < -20 Then
Text1(m) = y 10 ^ -2
End If
Next m
For k = 6 To 8
For n = 10 To 130
x = Int(Rnd n) - 30 '产生随机整数
Next n
For b = -15 To 30
y = x - b
Next b
If 80 < x Or 0 < x < 20 Or -20 < x < 0 Or x < -80 Or x = 0 Then
Text1(k) = ""
End If
If 20 < x < 80 Or -80 < x < -20 Then
Text1(k) = y 10 ^ -2
End If
If Text2(6) = "" Then
Text2(6) = 0
Text2(7) = 0
Text2(8) = 0
Text1(k) = 0
End If
Next k
End Sub
Private Sub Command2_Click()
If Text1(0) < 0 Then
Text1(0) = -Text1(0)
Text3(0) = Text2(0) - Text1(0)
Else
Text3(0) = Text2(0) + Text1(0)
End If
If Text1(1) < 0 Then
Text1(1) = -Text1(1)
Text3(1) = Text2(1) - Text1(1)
Else
Text3(1) = Text2(1) + Text1(1)
End If
If Text1(2) < 0 Then
Text1(2) = -Text1(2)
Text3(2) = Text2(2) - Text1(2)
Else
Text3(2) = Text2(2) + Text1(2)
End If
If Text1(3) < 0 Then
Text1(3) = -Text1(3)
Text3(3) = Text2(3) - Text1(3)
Else
Text3(3) = Text2(3) + Text1(3)
End If
If Text1(4) < 0 Then
Text1(4) = -Text1(4)
Text3(4) = Text2(4) - Text1(4)
Else
Text3(4) = Text2(4) + Text1(4)
End If
If Text1(5) < 0 Then
Text1(5) = -Text1(5)
Text3(5) = Text2(5) - Text1(5)
Else
Text3(5) = Text2(5) + Text1(5)
End If
If Text1(6) < 0 Then
Text1(6) = -Text1(6)
Text3(6) = Text2(6) - Text1(6)
Else
Text3(6) = Text2(6) + Text1(6)
End If
If Text1(7) < 0 Then
Text1(7) = -Text1(7)
Text3(7) = Text2(7) - Text1(7)
Else
Text3(7) = Text2(7) + Text1(7)
End If
If Text1(8) < 0 Then
Text1(8) = -Text1(8)
Text3(8) = Text2(8) - Text1(8)
Else
Text3(8) = Text2(8) + Text1(8)
End If
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Text2(0) = ""
Text2(1) = ""
Text2(2) = ""
Text2(3) = ""
Text2(4) = ""
Text2(5) = ""
Text2(6) = ""
Text2(7) = ""
Text2(8) = ""
Text3(0) = ""
Text3(1) = ""
Text3(2) = ""
Text3(3) = ""
Text3(4) = ""
Text3(5) = ""
Text3(6) = ""
Text3(7) = ""
Text3(8) = ""
Text1(0) = ""
Text1(1) = ""
Text1(2) = ""
Text1(3) = ""
Text1(4) = ""
Text1(5) = ""
Text1(6) = ""
Text1(7) = ""
Text1(8) = ""
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
End
End Sub
这是我以前做的相当于抽奖的程序你可以查考
以上就是关于VB中可用的抽奖程序的代码全部的内容,包括:VB中可用的抽奖程序的代码、vb 抽奖程序 修改、vb 编转盘抽奖程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)