Ticks to time...?

Wolfsnap

Newcomer
Joined
Jun 15, 2003
Messages
19
Location
North Carolina
Is there an easy way to convert a tick value (read as an integer) into a formated time display?

Or, to be more precise - what would be the beat way to create a "stopwatch" comparing the stopwatch time to the system clock time.

I have an application where a stopwatch-type timer would be a nice feature, but the application is fairly CPU intensive and is running on a 600MGZ Touchscreen IPC - meaning that setting up the stopwatch in a timer control is wayyyyy off. I'm not so concerned about the display (as far as the timer displaying every second that ticks by) as I am thet the timer be accurate. (These timed tests could be several hours long). I've gotten to the point where, when the timer is started, the current tick count is placed into a variable, then that variable is subtracted from the ongoing tick count - but I can't figure out how to get the resulting tick count to display as a formatted time.

HELP!!
 
Well, I may have come a bit closer to figuring it out. In my "start" button, I've got:
ProcStart = System.DateTime.Now
Timer1.Enabled = True

and in the timer I've got:
Dim ProcTimeSecs As Int16
Dim ProcTimeMins As Int16
Dim ProcTimeHours As Int16
ProcTimeSecs = System.DateTime.Now.Subtract(ProcStart).Seconds
Label8.Text = ProcTimeSecs
ProcTimeMins = System.DateTime.Now.Subtract(ProcStart).Minutes
Label9.Text = ProcTimeMins
ProcTimeHours = System.DateTime.Now.Subtract(ProcStart).Hours
lblHours.Text = ProcTimeHours

This seems to work OK - but is the code efficient?

Thanks.
 
It might be easier to use VB's builtin time formats...

System.DateTime.Now().ToString("s") returns 5 seconds
System.DateTime.Now().ToString("ss") returns 05 seconds
System.DateTime.Now().ToString("m") returns 5 mniutes
System.DateTime.Now().ToString("mm") returns 05 mniutes
System.DateTime.Now().ToString("h") returns 5 hourss
System.DateTime.Now().ToString("hh") returns 05 hours

same goes for d, dd, ddd or dddd for days and M, MM, MMM, MMMM for months or y, yy, yyyy for years

H and HH are for a 24 hour format and
t and tt return a or am

I think if used with DateDiff function it should work pretty well.

Hope that helps
 
Thanks for the quick responce! I'll delve into your suggestions. What I've written so far actually works fine as far as starting a timer routine based on the system clock - the problem I've got now is "pausing" the timer and picking it up where it left off. I'm guessing I need to place the time at which the timer was paused into some sort of variable and reload that variable into the routine when I restart the timer - but it's kickin my tail right now as to how to write it! It may well be a whole lot easier with your suggestions. Thanks and if you have any more suggestions - I'm more than willing to give 'em a whirl!
 
Just a quick question Wolfsnap...North Carolina is one of the hearts of US furniture manufacturing...is this project connected with that in any way?

Dan
 
Nope - I've done several projects for furniture people - the most no-paying-est people you'd ever want to meet. I've been stuck for several thousands worth from those "people", to use the term lightly.

This project is for an industrial grinder control panel interface (check http://www.vecoplanllc.com). The timer I need will enable customers to time, for example, how long it would take to grind a hopper full of plastic purge, or whatever (yup - sometimes it's furniture parts).
 
Thanks for the reply...I personally have been ripped off by them good 'ol boys for a patentable machine I designed and built. Too bad for them as I now hold a few more patents!

PC interfaced machinery is very cool...but PLC's can do everything you're asking...out of the box so to speak. Why a PC over a PLC?
 
Back
Top