how do you wait for less than one second in vb? i tried using secondstowait(number) but it rounds up to one second or rounds down and doesnt wait at all.
have a timer called timer with an interval of 1 and a button call button and use this Code (Text): Public miliseconds as long Private sub button_click timer1.enabled = true Do until milliseconds = 100 loop timer1.enabled = false end sub Private Sub Timer1_Timer() milliseconds = milliseconds + 1 End Sub[code]This will have the program wait for 100 miliseconds
well put a timer on your form and the interval is the number of miliseconds before the action in the timer takes place. Useually something = something + 1 and put If something >= time you want to wait Then do wahtever. Or if it is to record how long something took put Msgbox "it took" + something + " miliseconds to do something
Just use this: [edited SecondsToWait] Code (Text): Public Sub MilliSecondsToWait(lNumberOfSeconds As Long) Dim ft As FILETIME Dim lBusy As Long Dim lRet As Long Dim dblDelay As Double Dim dblDelayLow As Double Dim dblUnits As Double Dim hTimer As Long hTimer = CreateWaitableTimer(0, True, App.EXEName & "Timer") If Err.LastDllError = ERROR_ALREADY_EXISTS Then Else ft.dwLowDateTime = -1 ft.dwHighDateTime = -1 lRet = SetWaitableTimer(hTimer, ft, 0, 0, 0, 0) End If dblUnits = CDbl(&H10000) * CDbl(&H10000) If lNumberOfSeconds > 0 Then dblDelay = CDbl(lNumberOfSeconds) * 10000 Else dblDelay = 100000 End If ft.dwHighDateTime = -CLng(dblDelay / dblUnits) - 1 dblDelayLow = -dblUnits * (dblDelay / dblUnits - _ Fix(dblDelay / dblUnits)) If dblDelayLow < CDbl(&H80000000) Then dblDelayLow = dblUnits + dblDelayLow ft.dwHighDateTime = ft.dwHighDateTime + 1 End If ft.dwLowDateTime = CLng(dblDelayLow) lRet = SetWaitableTimer(hTimer, ft, 0, 0, 0, False) Do lBusy = MsgWaitForMultipleObjects(1, hTimer, False, _ INFINITE, QS_ALLINPUT&) DoEvents Loop Until lBusy = WAIT_OBJECT_0 CloseHandle hTimer End Sub
i did that and now it doesnt freeze, but it doesnt do anything else either. heres my code. Code (Text): Private Sub button_click() button.Visible = False Timer1.Enabled = True Do Until milliseconds = 100 Loop Timer1.Enabled = False button.Visible = True End Sub edit:didnt see rickys code... will try now. Edit2: ricky, i keep on getting compile errors in your procedure