Time Calculation w/ Macro

W

WLMPilot

I use a userform to obtain info about clocking in/out at work. This is a
simple user entry userform. Fields are Textbox2 (clock-in) and Textbox3
(clock-out). Time is entered based on 24-hr clock using colon, ie 17:23
(5:23pm).

I want to calculate total hours worked. Thus, I need to subtract, then
convert to hours. I am able to do this in a spreadsheet using HOURS() and
MINUTE(). However, I cannot get it to work in a macro. Here is an example
of what I need to happen as I have it in the spreadsheet (but using macro
fields). I need to perform same calculation in a macro.

User enters: Textbox2 = 8:00 Textbox3 = 17:23

Calculations after user clicks ENTER:
ttltime1 = Textbox3 - Textbox3 (should = 9:23)
ttltime2 = HOURS(ttltime1) +(MINUTE(ttltime1)/60) (should = 9.38)

ttltime2 will then be inserted into the spreadsheet.

I also need to know how to DIM all the fields.

Thanks in advance,
Les
 
J

Joel

ttltime1 = TimeValue(Textbox3) - TimeValue(Textbox2) (should = 9:23)
ttltime2 = HOURS(ttltime1) +(MINUTE(ttltime1)/60) (should = 9.38)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top