-
The following code takes the time from text1.text and text2.text and adds them up and places the new time in text3.text....it even notices that if minutes are more then 60 to add it to the hour section....now i need this code to do the same with the seconds.....so instead of 2:30 and 2:30 equals 5:00 I need 2:30:30 and 2:30:30 which would equal 5:01...got me? Heres the code
a=timevalue(text1)
b=timevalue(text2)
c=minute(a)
d=minute(b)
text3=hour(a)+hour _(b)& ":" & c + d
if (c+d) >=60 then
m=(hour(a) + hour _(b) + 1)
n=(c+d)-60
text3=m & ":" & n
End if
In the form load event add the following code:
Text1="2:30"
Text2="3:30"
-
I get a error
Expected: New or Interger or Long Or Single Or Double Or Currency or String or Varient or identifer.
and on the first line it highlightes the last "Date"
Dim Date1, Date2 As Date <---
-
TimeValue Function
You only need the TimeValue function to do it.
Assume:
- T1 is the text from Text1
- T2 is the text from Text2
- T3 is the result to Text3
Code:
Dim T1$, T2$, T3$
T1 = "2:30:30"
T2 = "3:30:30"
T3 = Format(TimeValue(T1) + TimeValue(T2), "HH:MM:SS")
:)
-
Thanks a lot
Dood, that one hit the spot. Thanks a lot, i been going crazy with the code i had.