I Need A Timer For Vbasic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pberardi
    New Member
    • Dec 2006
    • 5

    #1

    I Need A Timer For Vbasic

    Can someone please help? All I need is to display the elapsed time that it takes for a user to solve a particular puzzle. I am in school and my book doesn't explain it and the MSDN library seems too complicated for what I need. Can some post six-ten lines of code for me please?
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Originally posted by pberardi
    Can someone please help? All I need is to display the elapsed time that it takes for a user to solve a particular puzzle. I am in school and my book doesn't explain it and the MSDN library seems too complicated for what I need. Can some post six-ten lines of code for me please?
    Hi there,

    What do you mean by "Can some post six-ten lines of code for me please?"
    What should be the contents for those 16 lines?

    Comment

    • pberardi
      New Member
      • Dec 2006
      • 5

      #3
      Originally posted by sashi
      Hi there,

      What do you mean by "Can some post six-ten lines of code for me please?"
      What should be the contents for those 16 lines?
      That is my question. I dont want this to be a complicated matter at all. The code for this time should be short....that was my point.

      Comment

      • sashi
        Recognized Expert Top Contributor
        • Jun 2006
        • 1749

        #4
        Originally posted by pberardi
        That is my question. I dont want this to be a complicated matter at all. The code for this time should be short....that was my point.
        Hi there,

        Try in google & stop sending me PM. Good luck & Take care.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by pberardi
          Can someone please help? All I need is to display the elapsed time that it takes for a user to solve a particular puzzle. I am in school and my book doesn't explain it and the MSDN library seems too complicated for what I need. Can some post six-ten lines of code for me please?
          If you record the current system time form Now() into a variable (Eg. StartTime) at the beginning of the task, then to get elapsed time all you need do is subtract the two. Example
          Code:
          ' At start of task...
          Dim StartTime As Date ' Yes I know, but it includes Time as well. :)
          StartTime = Now()
          .
          .
          .
          ' When task is finished...
          Dim Elapsed As DateTime
          Elapsed = Now() - StartTime
          Another option, which may provide a more useful result, is to use the DateDiff function to return the number of a particular time unit between the two values. In other words, it can return the number of seconds, or hours, or whatever.Exampl e
          Code:
          Elapsed = DateDiff("s", StartTime, Now())
          If I got the syntax right, this will return the number of seconds between the start time and the current system time.

          Comment

          Working...