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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.