Hi everyone, I am very new to VB using VB6, I have gone through a basic home study tutorial to date.
I need some help please.
I would like to create a form that has a label box which I want to be able to enter a value of time in hours/min/sec and then I want to be able to click a command button to have this time countdown untill I click either another command button or the same one to stop the countdown, I also want to be able to show the total time that was counted down in the same format, I would also like to be able to save the running total count down into new records of my dbase (Access) for each time that I click to start/stop the countdown and get a different result.
The reason for this is that I want to set a time value and then record how long I speak to someone on the phone, by clicking the start/stop command button and record the time for each call in individual records of my database.
As I am self taught so far I am struggling with this and hope that one of you guru's out there can help.
Thanking you in advance.
R
Countdown TimerCountdown Timer
Page 1 of 1
1 Replies - 7908 Views - Last Post: 29 July 2007 - 09:17 AM
Replies To: Countdown Timer
#2
Re: Countdown Timer
Posted 29 July 2007 - 09:17 AM
Hello izcrab,
To do what you're looking for you need to be using the TimerControl (it's in the toolbox in VB6). You need to use the Timer_Click event to tell it what to do on each click (in this case have it click time off to record how long you've spoken with someone).
I will give you some basics on the TimerControl, then I want you take what I offer and try playing around with it to see if you can get to where you're trying to get. If not, post the code you're working with back here, with the problem/error you've receiving and myself or one of the other programmers here will help. I just dont feel that handing you 100% of the code you seek will help you to learn from it.
Create 2 global variables
In the loading of your form set the properties of your timer
Then in the Tick event of your timer control put the logic of what you want
Then in your buttons Click event (the one to start the timer)
Then in the button to stop the timer
This will get you started. In my opinion though I wouldnt go this route. Since you're storing the information into a database, with the click of the start button I would enter the time into the database, then with the click of the end button I would enter the time into the database, then I would use the DATEDIFF (In access) to calculate the difference, but thats just my opinion.
Hope this helps
To do what you're looking for you need to be using the TimerControl (it's in the toolbox in VB6). You need to use the Timer_Click event to tell it what to do on each click (in this case have it click time off to record how long you've spoken with someone).
I will give you some basics on the TimerControl, then I want you take what I offer and try playing around with it to see if you can get to where you're trying to get. If not, post the code you're working with back here, with the problem/error you've receiving and myself or one of the other programmers here will help. I just dont feel that handing you 100% of the code you seek will help you to learn from it.
Create 2 global variables
Dim temptime As Long Dim elapsed As Long
In the loading of your form set the properties of your timer
Private Sub Form_Load() Timer1.Interval = 1000 'This will set an interval of 1 second Timer1.Enabled = False End Sub
Then in the Tick event of your timer control put the logic of what you want
Private Sub Timer1_Timer() elapsed = Hour(now()*3600 +Minute(Now() * 60 + Second(Now())) Label2 = elapsed Label3 = (temptime - elapsed) & "Seconds" End Sub
Then in your buttons Click event (the one to start the timer)
Private Sub Command1_Click() Timer1.Enabled = True temptime =Hour(now()* 3600+ Minute(Now() * 60 + Second(Now())) + 30 ' this is for 30 seconds. change this to your need Label1 = temptime End Sub
Then in the button to stop the timer
Private Sub Command2_Click() Timer1.Enabled = False End Sub
This will get you started. In my opinion though I wouldnt go this route. Since you're storing the information into a database, with the click of the start button I would enter the time into the database, then with the click of the end button I would enter the time into the database, then I would use the DATEDIFF (In access) to calculate the difference, but thats just my opinion.
Hope this helps
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|