回复 2楼 wds1
你的程序里面没有实现数字滚动然后出现数字的功能,将你的程序
稍微修改了一下,窗体再加一个Timer控件就可以了,代码如下:
Option Explicit
Public b
Public index
Public TCount As Integer''时钟刷新次数
'抽签30个,点击抽签显示数字,不重复(抽一个少一个)
Private Sub Form_Load()
Timer1.Enabled = False
index = 1
Randomize
ReDim b(1 To 1) As Integer
b(1) = Int(Rnd * 30) + 1 '生成第一个随机标签标
Do
Call Diff1(Int(Rnd * 30) + 1, b) '生成后边的29个随机标签
Loop Until UBound(b) = 30
End Sub
Private Sub Command1_Click() '触发时钟
Timer1.Enabled = True
Timer1.Interval = 20
End Sub
Public Function Diff1(txt1, ByRef Array1) '如果txt不在array数组,则增加
Dim i As Integer
For i = 1 To UBound(Array1)
If txt1 = Array1(i) Then Exit For
DoEvents
Next
If i > UBound(Array1) Then
ReDim Preserve Array1(1 To i): Array1(i) = txt1
End If
End Function
Private Sub Timer1_Timer()
If index < 31 Then
TCount = TCount + 1
If TCount < 31 Then
Label1.Caption = Int(Rnd * 30) + 1
Else
Label1.Caption = b(index)
index = index + 1
Print b(index - 1);
TCount = 0
Timer1.Enabled = False
End If
Else
MsgBox ("完成抽签")
TCount = 0
Timer1.Enabled = False
End If
End Sub