Calculating Hours from Textbox Times

C

Corey ....

Private Sub TextBox9_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox8 <> "" And TextBox9 <> "" Then Label63 = (TextBox9.Value -
TextBox8.Value) * 24
End Sub

With the above line of code, i am trying to gain the value in Hours between
the 2 textboxes, but i get an error.

Textbox8.value = 3:30PM
Textbox8.value = 7:30AM

??
 
B

Bob Phillips

Private Sub TextBox9_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox8.Text <> "" And TextBox9.Text <> "" Then _
Label63.Caption = (TimeValue(TextBox9.Value) - _
TimeValue(TextBox8.Value)) * 24
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
C

Corey ....

Thank you BOB.

Perfect !!

Bob Phillips said:
Private Sub TextBox9_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox8.Text <> "" And TextBox9.Text <> "" Then _
Label63.Caption = (TimeValue(TextBox9.Value) - _
TimeValue(TextBox8.Value)) * 24
End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)
 

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