Solved

Delaying Code Execution for x milliseconds

Posted on 1998-10-27
2
253 Views
Last Modified: 2010-04-30
This should be simple for most of you.

I need to draw a graph in slow-motion so that people can see the drawing process step-by-step.

All I need to know is how to delay code execution at run-time in VB5. I know that in C++, all you need is the "delay" keyword followed by the no. of milliseconds.
But how do I do it in VB5 ? Can I do it without the timer control ?

Thanks
0
Comment
Question by:xoooox
2 Comments
 
LVL 1

Accepted Solution

by:
zivf earned 50 total points
ID: 1442004
you need to run a loop, and using the timer() function will be the most accurate. it returns the number of seconds since last midnight, and at least 2 more digits accurate to the right of the decimal point.
tmr = timer()
do while timer() < (tmr + wait_time)
    ' here you can put DoEvents if you want other tasks
    ' to get CPU time
loop
0
 

Expert Comment

by:BHimmerick
ID: 1442005
I believe this is the code you are looking for.

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

Just call Sleep for it to pause the number of Milliseconds you want it to.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now