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


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    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 Threads - Timer program Visual Date
Fortran Old timer's question Mar 25, 2016
Rubik's Cube Timer on Matlab Feb 22, 2013
Programming a 7 segment display timer Mar 1, 2010
A timer Interrupt to cause delay Nov 27, 2008
Problem with timer. Jul 22, 2008