How to concatenate multiple textboxes
Solved
coupidon
Posted messages
98
Status
Membre
-
Ant049 Posted messages 157 Status Membre -
Ant049 Posted messages 157 Status Membre -
Hello,
I have 3 textboxes where I input:
- hours in the first
- minutes in the second
- seconds in the third
I chose this configuration for aesthetics, anyway
I would like to perform a calculation in VBA on Excel using the current date and time with the function
now()
but how can we concatenate the 3 textboxes to allow this calculation?
Thanks to anyone who can help.....
I have 3 textboxes where I input:
- hours in the first
- minutes in the second
- seconds in the third
I chose this configuration for aesthetics, anyway
I would like to perform a calculation in VBA on Excel using the current date and time with the function
now()
but how can we concatenate the 3 textboxes to allow this calculation?
Thanks to anyone who can help.....
I want to enter in three textboxes, the hours in one, the minutes in the other and the seconds in the last
and with that I want to perform the calculation of the three textboxes with the now() at the moment and have it add those hours, you see?
An example:
textbox1: 5 hours
textbox2: 20 minutes
textbox3: 41 seconds
Let’s say that right now "now()" we are on Thursday, September 08, 2016, 10:06:06
and a textbox4 for example displays the result:
15:26:47
There you go, it seems simple in Excel but in VBA I’m struggling, so I thought about concatenation.
For the addition, you need to use the Time function in VBA, which will return the time with minutes and seconds.
Be careful with the formats! To add the two, you'll need to adjust the format; I'll let you figure that out and come back if you get stuck.
I tested your code, so here it is, like this it works, but I can't figure out how to use the Time function in this code.
When I use the variable H and want to perform calculations, it gives me errors, so I'm stuck...
I searched for VBA courses on the Time function, but with my concatenation, it bugs.
I'm not sure if it's treated as a time, so I can actually do the calculation.
Private Sub TextBox10_AfterUpdate()
Dim H As String
H = TextBox8.Value & ":" & TextBox9.Value & ":" & TextBox10.Value
TextBox16.Value = H
End Sub
You have the method to concatenate your textboxes.
Regarding adding the two times:
- try playing with the formats:
- look at functions like DateAdd.