Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

timer

Posted on 1999-07-31
9
Medium Priority
?
270 Views
Last Modified: 2010-04-30
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.
0
Comment
Question by:SamsonChung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 2

Expert Comment

by:BeedleGuis
ID: 1528757
could you describe in better detail what you are trying to do?  What type of objects, what events?
0
 
LVL 2

Expert Comment

by:JaganMohan
ID: 1528758
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
0
 
LVL 3

Expert Comment

by:kfrick
ID: 1528759
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

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Author Comment

by:SamsonChung
ID: 1528760
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
0
 
LVL 3

Expert Comment

by:piratepatrol
ID: 1528761
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.
0
 
LVL 6

Author Comment

by:SamsonChung
ID: 1528762
And where do i get the sleep thing?
0
 
LVL 1

Accepted Solution

by:
vbplus earned 200 total points
ID: 1528763
Try this

Sub Delay (T as Single)

Dim TP as Single

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

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!
0
 
LVL 3

Expert Comment

by:piratepatrol
ID: 1528764
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.


0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6872227
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.

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question