'计时器触发时屏幕上会滚动显示被抽奖人的姓名等资料(如果下面这段去掉姓名就不会在屏幕上滚动)
Private Sub Form_Timer()
Dim X As Integer, Y As Integer, I As Integer
On Error GoTo Err_Form_Timer
DoCmd.GoToRecord , , acFirst
X = Me.Recordset.RecordCount
Randomize
Y = Int(X * Rnd + 1)
DoCmd.GoToRecord , , , Y
Me.Repaint
Exit_Form_Timer:
Exit Sub
Err_Form_Timer:
MsgBox Err.Description
Resume Exit_Form_Timer
End Sub
Private Sub Command17_Click()
T=0
Me.TimerInterval = 1 '打开计时器,这里用的是1毫秒
End Sub
Private Sub Form_Timer()
Dim X As Integer, Y As Integer, I As Integer
T = T + 1
DoCmd.GoToRecord , , acFirst
X = Me.Recordset.RecordCount
Randomize
Y = Int(X * Rnd + 1)
DoCmd.GoToRecord , , , Y
Me.Repaint
If T = 500 Then '这里虽然用500毫秒,但实际上需要7秒左右才执行下面的代码,难道跟电脑运行速度有关?可是电脑配置很好哦
Me.Lottery = "Yes"
Me.Jiangji = "二等奖"
Me.TimerInterval = 0 '关闭计时器
End If
End Sub 作者: ycxchen 时间: 2010-11-20 09:27
Me.Lottery = "Yes"
Me.Jiangji = "二等奖"
只是赋值,不会500毫秒的需要7秒左右才执行?是不是代码还没有优化?发个例子上来如何?作者: todaynew 时间: 2010-11-20 16:44 本帖最后由 todaynew 于 2010-11-20 17:00 编辑