How to add two TextBoxes arithmetically?
How to add two TextBoxes arithmetically?
(OP)
Hi all,
I have just started learning VBA.
I have a small problem that I hope somebody may be able to help me out.
I was wondering how you add two TextBoxes together arithmetically.
My code is like this:
TextBox4.Text = TextBox3.Text + TextBox2.Text
but when I put in the data i.e 149 + 92 instead of adding it up to an answer of 241 it comes out 14992.
is there a way of adding up numerically.
thanks
Barry.
I have just started learning VBA.
I have a small problem that I hope somebody may be able to help me out.
I was wondering how you add two TextBoxes together arithmetically.
My code is like this:
TextBox4.Text = TextBox3.Text + TextBox2.Text
but when I put in the data i.e 149 + 92 instead of adding it up to an answer of 241 it comes out 14992.
is there a way of adding up numerically.
thanks
Barry.





RE: How to add two TextBoxes arithmetically?
Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting
Steam Engine enthusiasts: www.essexsteam.co.uk
RE: How to add two TextBoxes arithmetically?
Do you mean like
TextBox4.Value = TextBox3.Value + TextBox2.Value
I tried this before hand and it returned the same result.
Thanks
Barry
RE: How to add two TextBoxes arithmetically?
You want
TextBox4 = Val(TextBox3) Val(TextBox2)
Val extracts the numeric value in the text boxes
You may also need to trap errors in case there is no numeric value in one or other text.
RE: How to add two TextBoxes arithmetically?
TextBox4 = Val(TextBox3) + Val(TextBox2)
RE: How to add two TextBoxes arithmetically?
Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting
Steam Engine enthusiasts: www.essexsteam.co.uk
RE: How to add two TextBoxes arithmetically?
Strictly speaking, they do not intermingle. However, the "Variant" type does permit "cross-breeding."
If you're working inside Excel, you should be particularly cognizant of this. Many an error has arisen because the operator sees something as a number while the program is viewing it as text.
--------------------
Bring back the HP-15
www.hp15c.org
--------------------
RE: How to add two TextBoxes arithmetically?
TextBox4 = 1*(TextBox3) + 1*(TextBox2)
works too.
m777182