Results 1 to 3 of 3

Thread: VB - A different timing approach

  1. #1

    Thread Starter
    Lively Member Daniel McCool's Avatar
    Join Date
    Oct 2002
    Posts
    127

    VB - A different timing approach

    I messed around with the Timer control to time my runtime operations, but couldn't quite get it to work efficiently. I'm sure there is some great Timer code out there, or some similar, but here was my solution to timing my code ....

    VB Code:
    1. tempTimeStart = Time 'Capture the computers time before the operations (12:34:56 AM)
    2. tempTimeStart = Left$(tempTimeStart, Len(tempTimeStart) - 3) 'Cut off the AM part (12:34:56)
    3. temp = Split(tempTimeStart, ":") 'Split the time into hours, minutes, and seconds (12,34,56)
    4. tempTimeStart = (((temp(0) * 60) + temp(1)) * 60) + temp(2) 'Convert the hours into minutes, add on the minutes and convert them to seconds then add on the remaining seconds (((12*60)+34)*60)+56
    5.  
    6. DoEvents 'Operations ...
    7.  
    8. tempTimeEnd = Time 'The following code is same as above
    9. tempTimeEnd = Left$(tempTimeEnd, Len(tempTimeEnd) - 3)
    10. temp = Split(tempTimeEnd, ":")
    11. tempTimeEnd = (((temp(0) * 60) + temp(1)) * 60) + temp(2)
    12.  
    13. tempTime = tempTimeEnd - tempTimeStart 'Find the difference in the times

    .... basically caculating the time the code starts, and calculating the time it ends, then find the difference. Seems to work fine.

  2. #2

  3. #3
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994

    Yeah

    That's some otherwise nice thinking dude, good thing you can work around problems, but in this case GetTickCount is just better =).

    Cheers!
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width