Adding values in textboxes?
As previously answered:
In the Exit Event of each textbox put in the code
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Textbox4.Text = Format(clng(textbox1) + clng(textbox2) +
clng(textbox3),"0")
End Sub
Repeat for Textbox2 and Textbox3
You can also use the afterupdate event.
Change clng to csng if the numbers will be decimals/fractions.
your cint of the concatenated result is the right thought, but wrong answer.
What you seem to not know is that when dealing with strings the plus sign
(+) also acts as a concatenation operator - and all values in a textbox are
strings, even if they look like numbers.
--
Regards,
Tom Ogilvy
"Gary Phillips" wrote in message
...
Okay, stupid question.
I have 4 textboxes... three of them are enabled so the user can enter an
integer value in each of them.
The 4th one is disabled, it will display the total of the 3 values the
user enters.
So on the txtOption01_Change(), txtOption02_Change(), and
txtOption03_Change() event I want it to add those values together and
display their total in the 4th textbox.
The way it happens now is like this...
txtOption01 = 5
txtOption02 = 5
txtOption03 = 5
txtOption04 = 555
I even tried converting it to Int but that doesn't work.
txtOption04.Value = CInt(myInt)
Is that right?
|