Link to home
Start Free TrialLog in
Avatar of mr_avril
mr_avril

asked on

How to make hour/minutes/second counter

Hi experts,
I'm developing a simple application using VB and one of the output to display is total minutes starting from the application is open until it is close.

So i'm wondering how to make a counter that will count the minutes from the 1st minute until the last minutes which is when the application is close

Pls help

Thanks
Avatar of Nightman
Nightman
Flag of Australia image

use a Timer. You can set the interval every second (1000) if you want a 'seconds' part of your timer, and then simply increment the value that you are displayiing by 1 with every tick. If the value reaches 60, set to 00 and increment the minutes portion. If the minutes portion also reaches 60, increment the hours portion.

You can also set the timer interval to 60000 (60 seconds) if you only want it to count every minute.
Avatar of mr_avril
mr_avril

ASKER

Nvm.. I got it already :)

If i got another prob.. i find u guys again :)
anyway thanks
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If the user clicks away from the form, the clock may stop if using the timer object, giving you incorrect times

Have a look at this post - use GetTickCount when the program loads, and then refer to the current value of GetTickCount with the timer - if the clock is stopped by the loss of focus, it will catch up again when it regains focus

https://www.experts-exchange.com/questions/21974033/Timer-Freezes-frozen-when-user-right-clicks-on-title-bar.html
Hi mr_avril

Have our comments assisted you? If not, please can you provide some feedback, otherwise have a look at https://www.experts-exchange.com/help.jsp#hs5 for information on closing questions.

Regards
Nightman