Link to home
Start Free TrialLog in
Avatar of SamsonChung
SamsonChungFlag for Canada

asked on

timer

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.
Avatar of BeedleGuis
BeedleGuis

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
      ....Statements..
     IntCount = 2
Case 2
     .....Statements
    IntCount = 3
Case 3
    .....Statements
    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!
-kf

Avatar of SamsonChung

ASKER

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:

Sleep(1000)

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

Jesus loves you.
And where do i get the sleep thing?
ASKER CERTIFIED SOLUTION
Avatar of vbplus
vbplus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.


GREETINGS!

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.

https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange