大众信息网

我想用VB制作一个抽奖型的转盘

关注:111  答案:2  手机版
解决时间 2021-02-25 17:21
我的是VB6.0的软件. 请大家告诉我详细的代码.
最佳答案
这是一个转盘 转到的位置是随机的 具体奖品需要你自己定 我就不帮你了..... 这一句 If c > 95 Then Timer1.Interval = 0 这个95 改的越小 停的越快,转到的位置重复的几率也就越大 . 代码细看看, 数值都是活的 可以根据自己需要改.

'添加控件 timer1 command1 line1
Dim x1%, y1%
Dim a As String

Private Sub Command1_Click()
a = 0
Timer1.Interval = 50
End Sub

Private Sub form_load()
Me.AutoRedraw = True
x1 = Me.Width \ 2
y1 = (Me.Height - 405) \ 2
Line1.x1 = x1: Line1.y1 = y1
Me.DrawWidth = 5
Me.Circle (x1, y1), 3000
Line1.BorderWidth = 5
Line1.BorderColor = QBColor(14)
End Sub

Private Sub Timer1_Timer()
Randomize
c = Int((100) * Rnd + 1)
a = a + 1
If a > 24 Then Timer1.Interval = 100
If a > 40 Then Timer1.Interval = 200
If a > 48 Then
Timer1.Interval = 300
If c > 95 Then Timer1.Interval = 0
End If
b = (3.14 / 8) * a
Line1.X2 = Line1.x1 + (3000 * Sin(b))
Line1.Y2 = Line1.y1 - (3000 * Cos(b))
End Sub
全部回答
你还是弄一个摇号抽奖的吧,比转盘抽奖的方便多了
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!