1,453
社区成员




Private Sub Form_Load()
Me.AutoRedraw = True
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim t As Date
Print Now
t = Now
Do While DateDiff("s", t, Now) < 10 '耗费10秒时间
Loop
End Sub
Option Explicit
'一个timer,一个command,控件(数组)label1(0)一个,一个label2
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Function TimerTest(lab1 As Label, lab2 As Label) As Double
'返回执行时间
Const NUM = 30000
Dim i As Long
Dim t As Double
t = GetTickCount
For i = 1 To NUM
If i = 1 Or i = NUM Then
lab1.Caption = i
Else
lab2.Caption = i
End If
DoEvents
Next
TimerTest = GetTickCount - t
End Function
Private Sub Form_Load()
Dim i As Long
Timer1.Enabled = False
Timer1.Interval = 1000
For i = 1 To 9
Load Label1(i)
With Label1(i)
.Top = Label1(i - 1).Top + 300
.Visible = True
End With
Next
End Sub
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Timer1_Timer()
Static n As Long
Print TimerTest(Label1(n), Label2)
n = n + 1
If n = 10 Then
Timer1.Enabled = False
n = 0
End If
End Sub
Option Explicit
Dim i As Long
Private Sub Command1_Click()
Print Timer
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = False
Timer2.Interval = 750
Timer2.Enabled = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub Timer1_Timer()
For i = 1 To 5000000
DoEvents
Next
'MsgBox Timer
Print Timer
'Timer1.Enabled = False
End Sub
Private Sub Timer2_Timer()
Print "timer事件"
End Sub
Option Explicit
Dim i As Long
Private Sub Command1_Click()
Print Timer
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 750
Timer1.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub Timer1_Timer()
For i = 1 To 5000000
DoEvents
Next
MsgBox Timer
'Print Timer
'Timer1.Enabled = False
End Sub
Option Explicit
Dim i As Long
Private Sub Command1_Click()
Print Timer
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
For i = 1 To 5000000
DoEvents
Next
'MsgBox Timer
Print Timer
Timer1.Enabled = False
End Sub
Option Explicit
Dim i As Long
Private Sub Command1_Click()
Debug.Print Timer
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
For i = 1 To 5000000
DoEvents
Next
MsgBox Timer
Debug.Print Timer
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
For i = 1 To 10000000
DoEvents
Next
Debug.Print Timer
Timer1.Enabled = False
End Sub