ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add the values of TextBoxes (https://www.excelbanter.com/excel-programming/426967-add-values-textboxes.html)

Patrick C. Simonds

Add the values of TextBoxes
 
I am attempting to add these TextBox Values and place the results into
TextBox503 but am having no luck. It will place the value of TextBox1 into
TextBox503 but will not add the values in the other TextBoxes.



Private Sub TextBox1_Change()

TextBox503.Value = CDbl("0" & TextBox1.Value) + CDbl("0" & TextBox2.Value) +
CDbl("0" & TextBox3.Value)
TextBox503.Text = Format(TextBox1.Text, "0.0000")

End Sub


Rick Rothstein

Add the values of TextBoxes
 
It does that because you used TextBox1 as the argument for the Format
function call instead of TextBox503. This is what you want...

TextBox503.Text = Format(TextBox503.Text, "0.0000")

--
Rick (MVP - Excel)


"Patrick C. Simonds" wrote in message
...
I am attempting to add these TextBox Values and place the results into
TextBox503 but am having no luck. It will place the value of TextBox1 into
TextBox503 but will not add the values in the other TextBoxes.



Private Sub TextBox1_Change()

TextBox503.Value = CDbl("0" & TextBox1.Value) + CDbl("0" & TextBox2.Value)
+ CDbl("0" & TextBox3.Value)
TextBox503.Text = Format(TextBox1.Text, "0.0000")

End Sub



Harald Staff[_2_]

Add the values of TextBoxes
 
Apologies for disagreeing, I'd do this:

Private Sub TextBox1_Change()
Call Sum503
End Sub

Private Sub TextBox2_Change()
Call Sum503
End Sub

Private Sub TextBox3_Change()
Call Sum503
End Sub

Private Sub Sum503()
Dim DD As Double
DD = Val(TextBox1.Value) + Val(TextBox2.Value) + Val(TextBox3.Value)
TextBox503.Text = Format(DD, "0.0000")
End Sub

Best wishes Harald

"Rick Rothstein" wrote in message
...
It does that because you used TextBox1 as the argument for the Format
function call instead of TextBox503. This is what you want...

TextBox503.Text = Format(TextBox503.Text, "0.0000")

--
Rick (MVP - Excel)


"Patrick C. Simonds" wrote in message
...
I am attempting to add these TextBox Values and place the results into
TextBox503 but am having no luck. It will place the value of TextBox1 into
TextBox503 but will not add the values in the other TextBoxes.



Private Sub TextBox1_Change()

TextBox503.Value = CDbl("0" & TextBox1.Value) + CDbl("0" &
TextBox2.Value) + CDbl("0" & TextBox3.Value)
TextBox503.Text = Format(TextBox1.Text, "0.0000")

End Sub





All times are GMT +1. The time now is 05:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com