Use GetTickCount for accuracy up to 1ms. Make a Form with 2 CommandButtons (cmdStart and cmdStop) and put the following code into your Form.
Code:Private Declare Function GetTickCount Lib "kernel32" () As Long Dim ContTime As Boolean Sub TimerEx(Interval As Long) Do While ContTime = True Start = GetTickCount Do While GetTickCount < Start + Interval DoEvents Loop '<--Place code here--> Print "Hello" Loop End Sub Private Sub cmdStart_Click() ContTime = True TimerEx (1000) End Sub Private Sub cmdStop_Click() ContTime = False End Sub




Reply With Quote