'' Put this where ever you want to wait for a certain amount of time '' amount of time you want to wait for Dim timeamount As Double = 50 '' the type of time you want. '' Possible types: Milliseconds, Seconds, Minutes, Hours, Days, Months, Years '' if you dont put something in, its default in the procedure will be "Milliseconds" Dim timeType as String = "Milliseconds" '' code you put if you want to wait Wait (timeamount, timeType) '' you can also change timeamount to a certain integer (eg. 40) '' you can also set timeType to a certain string, possible types are above. '' E.G. Wait (5000, "Milliseconds") '' 5 seconds '' You can also remove the timeType, but if done, it will default to milliseconds ''Example of that: Wait (5000) '' wait for 5 seconds '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' procedure Wait Public Sub Wait(ByVal amountOfTime As Double, Optional ByVal interval As String = "Milliseconds") Const time As Double = 1.0# / (1400.0# * 60.0#) Dim waitUntil As Date If interval = "Milliseconds" Or interval = "milliseconds" Then '' sets milliseconds as an option Now.AddMilliseconds(time) waitUntil = Now.AddMilliseconds(time).AddMilliseconds(amountOfTime) ElseIf interval = "Seconds" Or interval = "seconds" Then '' sets seconds as an option Now.AddSeconds(time) waitUntil = Now.AddSeconds(time).AddSeconds(amountOfTime) ElseIf interval = "Minutes" Or interval = "minutes" Then '' sets minutes as an option Now.AddMinutes(time) waitUntil = Now.AddMinutes(time).AddMinutes(amountOfTime) ElseIf interval = "Hours" Or interval = "hours" Then '' sets hours as an option Now.AddHours(time) waitUntil = Now.AddHours(time).AddHours(amountOfTime) ElseIf interval = "Days" Or interval = "days" Then '' sets days as an option Now.AddDays(time) waitUntil = Now.AddDays(time).AddDays(amountOfTime) ElseIf interval = "Months" Or interval = "months" Then '' sets months as an option Now.AddMonths(time) waitUntil = Now.AddMonths(time).AddMonths(amountOfTime) ElseIf interval = "Years" Or interval = "years" Then '' sets years as an option Now.AddYears(time) waitUntil = Now.AddYears(time).AddYears(amountOfTime) Else '' defaults to milliseconds if inputted wrong Now.AddMilliseconds(time) waitUntil = Now.AddMilliseconds(time).AddMilliseconds(amountOfTime) End If '' pauses until amount of time has passed Do Until Now > waitUntil '' allows windows messages and events to continue while pausing Application.DoEvents() Loop End Sub
Comments
0 B
|👍
/👎