Hi, everyone. :wave:
My question is:
How to display a message with a delay?
Thanks.
Printable View
Hi, everyone. :wave:
My question is:
How to display a message with a delay?
Thanks.
Can someone help me on this.
with a delay in the sense??
add a timer set the interval for say 5 seconds then call the event
just a wild idea!!
Can you give me a sample code?
this will show your msgbox after 5 secondsCode:Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Delay(ByVal delayInSeconds As Integer)
Dim targetTime As Date
targetTime = DateAdd("s", delayInSeconds, Now())
While targetTime > Now
Sleep 50 ' reduce CPU usage
DoEvents ' keep app responsive
Wend
End Sub
Private Sub Command1_Click()
Delay (5)
MsgBox "A"
End Sub
why not just use a timer as you originally suggested:
VB Code:
Private Sub Timer1_Timer() MsgBox "TEST" End Sub Private Sub Command1_Click() Timer1.Interval = 5000 Timer1.Enabled = True End Sub