Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

clocking on and off

Posted on 2004-08-17
4
Medium Priority
?
191 Views
Last Modified: 2013-12-25
I want to create a form thatw ill me to code in a clock-on and clock-off system and then calculate the expired time bewteen clocking on and off.
0
Comment
Question by:vbhel1
1 Comment
 
LVL 18

Accepted Solution

by:
JR2003 earned 1000 total points
ID: 11829349
Take a new form add 2 buttons, 2 textboxes and a label.
Paste in the following code

Option Explicit
Private dtClockOn As Date
Private dtClockOff As Date
Private sglTimeWorked As Single

Private Sub Command1_Click()
    'Clock On
    dtClockOn = Now()
    Text1.Text = Format(dtClockOn, "hh:mm:ss")
End Sub

Private Sub Command2_Click()

    'Clock Off
    dtClockOff = Now()
    Text2.Text = Format(dtClockOff, "hh:mm:ss")
    sglTimeWorked = dtClockOff - dtClockOn + 1
    Label1.Caption = IIf(sglTimeWorked >= 1, Fix(sglTimeWorked) & " Days ", "") & Format(sglTimeWorked, " hh:mm:ss")
End Sub

Private Sub Form_Load()

    Command1.Caption = "Clock On"
    Command2.Caption = "Clock Off"

End Sub
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question