• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:


i would like to put a delay for my objects to run... how do i do that?
the timer event help didn't mention anything on this please help me.
1 Solution
could you describe in better detail what you are trying to do?  What type of objects, what events?
In General we have a Timer Event for this, with specified Interval property set interms of milliseconds i.e. 1000 means 1 sec

In the Timer Event you have to write code like this

Static IntCount As Integer

Select Case IntCount
Case 1
     IntCount = 2
Case 2
    IntCount = 3
Case 3
    IntCount = 1
End Select  

You can also check the "DoEvents" in VB
I like to have my form open first, then turn on the controls. Here's how I do it:

On the Form, Drag a Timer object. Call it tmrStartUp. Set it's properties to
  Enabled = TRUE
  Interval = 200 (200 mS delay)

Now put this code behind the form:

Sub tmrStartUp_Timer
  tmrStartUp.Enabled = False      'keeps the timer from running again!
  'Place your strat-up code here
End Sub

Hope this helps!

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

SamsonChungAuthor Commented:
i am still not sure how to use it.
in this personnal project that i am doing, i have six pictures
i want them to show up one after the other like the wheels of a slotmachine
If i am using another language called Turing, i know it will be Delay(###)
is there are similar function for vb? or do i have to use the timer?
and how excactly to activate it? i tried it, but it saids error every time
Use the "Sleep" function...

In the general declaration of a module, place the following:

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

In the code area of your form, wherever you want a delay, just type:


Choose your own number inside the parenthesis.  I think 1000 will cause a
1 second delay.

Jesus loves you.
SamsonChungAuthor Commented:
And where do i get the sleep thing?
Try this

Sub Delay (T as Single)

Dim TP as Single

TP = Timer
Do Until Timer>TP+T Or Timer < 1

End Sub

This sub will delay execution for T seconds and you can use fractions of a second (eg. 0.5)

Use this sub prior to showing one of your pics. If you need a random interval use Rnd.

Hope this will help!
It's not a control.  You don't get it anywhere.  You type it in the code section of your form.  Here's an example:

In module 1, type...

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

In the code section of your form, type...

Private Sub Form_Activate()
    Print "Jesus"
    Sleep (1000)
    Print "Loves"
    Sleep (1000)
    Print "You"
End Sub

This will output the sentence one word at a time with a 1 second delay between each word.  Try it.

Jesus is Lord.


This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

Thank you,
Moderator @ Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now