how can I make the program wait? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how can I make the program wait?

tcf4tcf4 Posts: 49Member
I am writing a program that is talking to different types of hardware. I need to make the program wait 1 second before making the call to talk to a different piece of equipment, but I'm not sure how to do that. I initially put in a timer that it called, but when it called the timer function, it kept going through the sub routine and made the equipment call at the same time. How can I fix this?

Comments

  • iwilld0itiwilld0it Posts: 1,134Member
    Add this to a VB form for example ...


    [code]
    Option Explicit

    Private Declare Function GetTickCount Lib "kernel32" () As Long

    Sub Wait(numSeconds As Long)
    Dim start As Long
    start = GetTickCount() + (numSeconds * 1000)

    Do While start > GetTickCount()
    DoEvents
    Loop
    End Sub
    [/code]

    If you want the code to wait a second ...

    [code]
    Wait 1
    [/code]
Sign In or Register to comment.