Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Timer program in Visual Basic

  1. May 7, 2014 #1
    I've debugged and run my program without seeing any results from my "destinationVariable".
    What could be wrong?

    sub main()

    call myfunction()

    end sub

    sub myfunction()

    static myClock As Single

    myClock = timer

    if (timer - myClock) > 100 Then
    destinationVariable += 1 // This variable is linked to this script
    End If

    End Sub

    // I want the function to run in a loop, but I guess I don't need to use the do loop function to make that happen?
     
  2. jcsd
  3. May 7, 2014 #2

    FactChecker

    User Avatar
    Science Advisor
    Gold Member

    Since these lines execute right after each other, I doubt that the "if" test will ever be true unless the program gets interrupted between the two statements. That would be "rare". It may happen occasionally if you put this in a hard loop and run it continuously, but the odds on any one run are very small.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Timer program in Visual Basic
Loading...