I have a label which I want to present a message on so it will write it letter after letter.
This writes the first letter of Msg
and then gets stuck.
I played with the delay time but it doesn’t help.
Private Sub ShowEvent (Msg As String)
Dim X As Integer
For X = 1 To Len (Msg)
EventsDesc.Caption= Left (MSG, x)
Application.Wait (Now+TimeValue ("00:00:01"))
Next X
End Sub
8
Use the Timer function to calculate times less than a second along with DoEvents to pass control to the operating system.
I found 0.1 is fast enough that the user won’t get bored waiting for the label to populate.
Private Sub ShowEvent(Msg As String)
Dim X As Integer
Dim t As Double
For X = 1 To Len(Msg)
EventsDesc.Caption = Left(Msg, X)
t = Timer
Do Until Timer - t >= 0.1
DoEvents
Loop
Next X
End Sub
0