Solved

sleep or wait function in VB

Posted on 2001-06-12
3
1,460 Views
Last Modified: 2011-04-14
Is there a way to code a sleep or wait function in VB?
0
Comment
Question by:arichee
[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
3 Comments
 
LVL 4

Accepted Solution

by:
beckingh earned 100 total points
ID: 6183584
yep...

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

'Puts the app to sleep for the given number of milliseconds
'
'  Sleeps for a given number of seconds.
'
Public Sub Pause(ByVal seconds As Single)
   Call Sleep(Int(seconds * 1000#))
End Sub
0
 
LVL 2

Expert Comment

by:bhh
ID: 6183600
Sub Wait10Sec()
    Dim dtGoal As Date
    dtGoal = DateAdd("s", 10, Now)
    Do While dtGoal > Now
    Loop
End Sub
0
 
LVL 4

Expert Comment

by:mcoop
ID: 6183641

And now for the difference...

The first 'sleep' API will halt processing in your app for the duration of the sleep() routine.

The latter do-while-loop structure will allow you to call other processes within the loop if required (e.g. flash a message on the screen etc)

0

Featured Post

Technology Partners: 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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

739 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