Daniel McCool
Dec 17th, 2003, 04:36 PM
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 ....
tempTimeStart = Time 'Capture the computers time before the operations (12:34:56 AM)
tempTimeStart = Left$(tempTimeStart, Len(tempTimeStart) - 3) 'Cut off the AM part (12:34:56)
temp = Split(tempTimeStart, ":") 'Split the time into hours, minutes, and seconds (12,34,56)
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
DoEvents 'Operations ...
tempTimeEnd = Time 'The following code is same as above
tempTimeEnd = Left$(tempTimeEnd, Len(tempTimeEnd) - 3)
temp = Split(tempTimeEnd, ":")
tempTimeEnd = (((temp(0) * 60) + temp(1)) * 60) + temp(2)
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.
tempTimeStart = Time 'Capture the computers time before the operations (12:34:56 AM)
tempTimeStart = Left$(tempTimeStart, Len(tempTimeStart) - 3) 'Cut off the AM part (12:34:56)
temp = Split(tempTimeStart, ":") 'Split the time into hours, minutes, and seconds (12,34,56)
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
DoEvents 'Operations ...
tempTimeEnd = Time 'The following code is same as above
tempTimeEnd = Left$(tempTimeEnd, Len(tempTimeEnd) - 3)
temp = Split(tempTimeEnd, ":")
tempTimeEnd = (((temp(0) * 60) + temp(1)) * 60) + temp(2)
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.