Computing.Net > Forums > Office Software > Format Label Using Vba

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Format Label Using Vba

Reply to Message Icon

Name: mherber2
Date: July 6, 2008 at 10:28:11 Pacific
OS: Unknown
CPU/Ram: Unknown
Product: Unknown
Comment:

Currently i have a stopwatch(SW) created using excel vba. The SW has three buttons, one to start(cmdStart), one to stop(cmdStop), and one to reset(cmdReset). The elapsed time is displayed in a label(Timer). Everything is working good, the SW is accurate, the only problem that i am having is that the SW is only counting in seconds. what i really need is for the SW to count hour:min:sec. I have tried formating Timer to "hh:mm:ss" but vba will not count it. My question is: How can i format Timer to make it work the way i need it to? the code that i am currently using is as fallowed:

Located in Sheet3 (SW location):

Private Sub cmdReset_Click()
Sheet3.Timer.Caption = 0
cmdStart.Enabled = True
cmdStop.Enabled = False
cmdReset.Enabled = True
End Sub

Private Sub cmdStart_Click()
cmdStart.Enabled = False
cmdStop.Enabled = True
cmdReset.Enabled = False
StartTimer
End Sub

Private Sub cmdStop_Click()
cmdStart.Enabled = True
cmdStop.Enabled = False
cmdReset.Enabled = True
End Sub


Located in Module1:

Public RunWhen As Double
Public Const cRunWhat = "The_Sub"


Sub StartTimer()
Application.ScreenUpdating = True
RunWhen = Time() + TimeSerial(0, 0, 1)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub

Sub The_Sub()

Sheet3.Timer.Caption = Sheet3.Timer.Caption + 1
If Sheet3.cmdStart.Enabled = False Then _
StartTimer
End Sub


Can some one please help me? I have been working on this for days.



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Format Label Using Vba

Using VBA for Cond Formatting www.computing.net/answers/office/using-vba-for-cond-formatting/7726.html

Date format in Excel www.computing.net/answers/office/date-format-in-excel/4728.html

colors in excel vba www.computing.net/answers/office/colors-in-excel-vba/6989.html