Function Wait (numseconds As Long)
Dim start As Variant, rightnow As Variant
Dim HourDiff As Variant, MinuteDiff As Variant, SecondDiff As Variant
Dim TotalMinDiff As Variant, TotalSecDiff As Variant
start = Now
While True
rightnow = Now
HourDiff = Hour(rightnow) - Hour(start)
MinuteDiff = Minute(rightnow) - Minute(start)
SecondDiff = Second(rightnow) - Second(start) + 1
If SecondDiff = 60 Then
MinuteDiff = MinuteDiff + 1 ' Add 1 To minute.
SecondDiff = 0 ' Zero seconds.
End If
If MinuteDiff = 60 Then
HourDiff = HourDiff + 1 ' Add 1 To hour.
MinuteDiff = 0 ' Zero minutes.
End If
TotalMinDiff = (HourDiff * 60) + MinuteDiff' Get totals.
TotalSecDiff = (TotalMinDiff * 60) + SecondDiff
If TotalSecDiff >= numseconds Then
Exit Function
End If
DoEvents
'Debug.Print rightnow
Wend
End Function |