Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

a delay in visual basic

  • 22-04-2004 05:10PM
    #1
    Registered Users, Registered Users 2 Posts: 1,291 ✭✭✭


    I am programming an IC tester in visual basic for a college project. It works fine except it runs the tests too fast. I was wondering if there is a simple way to pause or delay the program for a second or 2 before performing the next line of code. I'm not great at programming using visual basic so an explanation in the simplest form would be appreciated.

    Cheers

    eoinf


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 2,427 ✭✭✭ressem


    http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20843293.html

    Look at sleep and delay routines.
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    

    Use with
    Sleep (3000)  '// Will pause for 3 seconds
    

    Problem is that this will freeze other events, so the "delay" routine, listed at the link above,
    1 calls sleep for a fraction of a second,
    2 calls doevent to make the interface respond to the user, and
    if time spent is less than the specified number of seconds go to 1


  • Registered Users, Registered Users 2 Posts: 1,291 ✭✭✭eoinf


    i keep getting errors

    where do i put the first line of code

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


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    unless VB has changed that radically you shouldn't need the declare statement. VB should have a sleep command built in.


  • Registered Users, Registered Users 2 Posts: 629 ✭✭✭str8_away


    Originally posted by eoinf
    i keep getting errors

    where do i put the first line of code

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

    with VB6 (not sure about other versions

    if you are putting the declaration in a module then you not need to change.

    if you are putting the declaration at the top of you code where you put global variable make the declare private.
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Advertisement