Please Help me finding the waiting fucntion in VB

accesser

Registered User.
Local time
Today, 06:19
Joined
Mar 17, 2003
Messages
54
I know that this Forum is for Access Programming, but because I need this issue urgently, I use this honored forum. The required thing is a very easy for a bigginer programmer, My question is that How can I use wait fucntion. I mean is there a wait function in the VB. I need to make animation of an object but the thing happen when run take place is that I find this object going very fast so it appears at its last place. I want this happen slowly so the user can see the object animated.

Regards,
 
In VB you need to create a Timer Object and place it on your form. You can set it's TimerInterval property in milliseconds and make use of its OnTimer event to perform actions.
 
You may be able to use the timer property of your form. Look up 'On Timer' & 'Timer Interval' in Help..
 
The Timer Control will not be useful here. This is because that the statements I wrote in the same event of the command1. This will cause that these statement will be executed one by one in a sequential order in a very fast running. What I want to do is to separate between them in execution. To be clear, please check the following:

Private Sub Command1_Click()

Label1.BackColor=&H000000FF&
Label1.BackColor=&H00FF0000&
Label1.BackColor=&H00404040&

End Sub

I want the change of their color will be visible for the user when he press command1. What is happening is that when you press the command1, the label1.backcolor will be directly &H00404040& . So Please help me

Regards,
 
Create a sub using the timer to switch the colours, then call it from the click event of your button.

Good luck...
 
You could create a WAIT function that handles the delay by checking TIMER and throw a couple doevents in for good measure.
I've used in in access to change the color of a see through image (button) for a special project.

Sub ChgButColor(Frm As Form, Cntrl As String)
Dim HoldColor As Long, Delay As Long
HoldColor = Frm(Cntrl).ForeColor
Frm(Cntrl).ForeColor = 32768
DoEvents
Delay = Timer + 0.5
Do Until Timer > Delay: Loop
Frm(Cntrl).ForeColor = HoldColor
End Sub

This basically took whatever color the text color was, changed it to dark green, then changed it back after waiting about (really, I mean ABOUT) half a second. In the real world it can be anywhere from 1/4 to 3/4 of a second (might just be an Access thing). But something like this might work for you also.
 
Or you could try the Sleep API. Put the following in the declarations section of your module

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Then call it within your code using

Sleep 500 ' 500 milliseconds, alter as you need
 

Users who are viewing this thread

Back
Top Bottom