-
Feb 25th, 2014, 09:17 AM
#1
Thread Starter
New Member
How to create a simple timer that starts when you run program?
I want to make a label that shows how long the program runs in seconds. Any ideas? I am still a beginner in VB6.
-
Feb 25th, 2014, 09:22 AM
#2
Re: How to create a simple timer that starts when you run program?
Are you really using VB6?
It is hard to come by legitimately anymore, and many have been fooled by aggressive marketing into thinking the freebie VB.Net Express is VB6. They are actually quite different things.
-
Feb 25th, 2014, 09:25 AM
#3
Re: How to create a simple timer that starts when you run program?
Add your label to your form. Add a timer control to your form. Set the Interval of it to 1000. Keep the Enabled Property set to True
add this code (double clikc on the timer and you only have to enter the middle line:
Code:
Private Sub Timer1_Timer()
Label1.Caption = Now
End Sub
You can play around with the FORMAT command if you don't like what that label caption looks like/displays.
EDIT: Good point, dile.....you posted as I was typing.
-
Feb 25th, 2014, 09:28 AM
#4
Re: How to create a simple timer that starts when you run program?
AND, what I posted is not quite what you want, but I'll let you figure that out. Get the time the program starts (NOW) in the form load routine. Save that and then calculate the difference every second in the timer. Very easy...let's see if you can do that. (IF you are using VB6, that is.)
-
Feb 25th, 2014, 09:39 AM
#5
Thread Starter
New Member
Re: How to create a simple timer that starts when you run program?
-
Feb 25th, 2014, 09:41 AM
#6
Thread Starter
New Member
Re: How to create a simple timer that starts when you run program?
-
Feb 25th, 2014, 09:43 AM
#7
Re: How to create a simple timer that starts when you run program?
So, have you figured out how to do this yet?
Use the DateDiff function when you compare the start time (NOW()) with the current time every second in the timer.
I have your solution, but want to see if you can get it yourself.
Do what I said above (except the line in the timer)---you will be replacing that with a different line using DateDiff. Also, set a global variable like "startTime" in the form_load so you can compare that every second with the CURRENT time in the timer.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|