VBA Form - Need Button - Time - Start & pause

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,232
Dear All

Is it possible to do start and pause the time on VBA Form..?

For example,
I have select any activity type from Combo box 1.

Time start in Text box.

after half an hour, user wants to take a break. Here, user can click a button say, "Pause". It will stop that time, and if he selects break option then break option text box time will start..

When again resume from break, user will stop the break time and will start the activity which he placed in "pause"

Can anyone please suggest on this...
 
Hi Logit..Thanks..

No. I dont have to say anything now...If you have something to publish, please go ahead..I want to see that (im eager to see the magic)..

Many Thanks..
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hey Logit, Im explaining once again step by step..


- The reason to create form is, to track user time daily basis.


- User will copy case id and will paste in "TxtTaskID" i.e. Text box.


- once case id paste in above text box, timer should start.


- if user want to pause work due to any reason.
For example:- User wants to go on Break then user will click on somewhere say, "Stop" button, where time goes in pause condition.


- The moment user will come back from break or from any other activity, the original time should start.




Here, "Chrono 02 button" we can use Logit. But It need code modification.




I need one clock where; when text box value is get filled then time start.


I need 2nd clock where; when user wanted to pause his above core activty and will start another clock time.


When User will return from break Or from other activity, 2nd time clock should stop and time details submitted to any other sheet. And main time 1st clcok should start.
 
Upvote 0
How do i modify this code,
Code:
Private Sub TButton1_Click()
    With TButton1
        If .Value = True Then
            .Caption = "Stop"
            .ForeColor = &H80&
            mTimer2.TimerOn 1000
        Else
            .Caption = "Start"
            .ForeColor = &H8000&
            mTimer2.TimerOff
        End If
    End With
End Sub
into, using text box
Code:
Private Sub TxtTaskID_Change()


    With TButton1
        If .Value = True Then
            .Caption = "Stop"
            .ForeColor = &H80&
            mTimer2.TimerOn 1000
        Else
            .Caption = "Start"
            .ForeColor = &H8000&
            mTimer2.TimerOff
        End If
    End With


End Sub
 
Upvote 0
Hi Logit,
One more update on this...I did copy all the details i.e. Chrono 2 button details as it is in my form. All the code as well, but im getting an error on..
Private Sub TButton1_Click()
With TButton1
If .Value = True Then
.Caption = "Stop"
.ForeColor = &H80&
mTimer2.TimerOn 1000
Else
.Caption = "Start"
.ForeColor = &H8000&
mTimer2.TimerOff
End If
End With
End Sub
Variable not defined..

can you pls help on this too..Thanks..
 
Upvote 0
Hi Logit,
Please ignore post no. 18. It is solved.

And also, please ignore my queries related "Chrono buton 2" also.

I tjink the best suitable is "Chrono button 1", which have 2 button, start and stop.

What I need only is...My post no. #17 . Please help me in modify that code...

Please revert..
 
Upvote 0
Hi Logit..

I need one help regarding workbook you shared..Could you revert on this pls..

1st Chrono 01 button...on that you have also provided, micro second facility...
I dont want that..could you guide me in removing this please..

.
Paste into a UserForm that has 1 Label and 2 Command Buttons :

Code:
Option Explicit


Private Sub BtnRaz_Click()
    mTimer2.TimerOff
    LblTemps.Caption = "00:00:00"


    With TButton1
        .Caption = "Start"
        .ForeColor = &H8000&
        .Value = False
    End With
End Sub


Private Sub TButton1_Click()
    With TButton1
        If .Value = True Then
            .Caption = "Stop"
            .ForeColor = &H80&
            mTimer2.TimerOn 1000
        Else
            .Caption = "Start"
            .ForeColor = &H8000&
            mTimer2.TimerOff
        End If
    End With
End Sub


Private Sub UserForm_Initialize()
    With TButton1
        .Caption = "Start"
        .ForeColor = &H8000&
        .Value = False
    End With
End Sub


Private Sub UserForm_Terminate()
    mTimer2.TimerOff
    Unload Me
End Sub

Download workbook : https://www.amazon.com/clouddrive/share/a8s89fz643VAb5X50lxdDShgC8nujn33xicZ0VMxwEe

There are three examples of a Timer In A Form. You want to look at Chrono 2
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,125,000
Members
449,202
Latest member
Pertotal

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top