![]() |
Convert text to Long
Hi,
I suspect that this is really easy but I haven't been able to figure out the solution. I have a form that holds a couple of numbers in text boxes, eg: TextBox1.Value is 2,000 TextBox2.Value is 12,500 What I want to do is add these two as numbers and display the answer in TexBox3. There will be no further manipulation of the value in TextBox3, so I don't actually care if it stored as a number or as text, so long as it is diaplayed as 14,500 TIA Dave TIA |
Convert text to Long
Hi,
If the commas aren't there you can use TextBox3.Value = Val(TextBox1.Value) + Val(TextBox2.Value) If the commas are real use TextBox3.Value = CLng(TextBox1.Value) + CLng(TextBox2.Value) Mike "Risky Dave" wrote: Hi, I suspect that this is really easy but I haven't been able to figure out the solution. I have a form that holds a couple of numbers in text boxes, eg: TextBox1.Value is 2,000 TextBox2.Value is 12,500 What I want to do is add these two as numbers and display the answer in TexBox3. There will be no further manipulation of the value in TextBox3, so I don't actually care if it stored as a number or as text, so long as it is diaplayed as 14,500 TIA Dave TIA |
Convert text to Long
You wanted the comma
myval = CLng(TextBox1.Value) + CLng(TextBox2.Value) TextBox3.Value = Left(myval, Len(myval) - 3) & "," & Right(myval, 3) Mike "Mike H" wrote: Hi, If the commas aren't there you can use TextBox3.Value = Val(TextBox1.Value) + Val(TextBox2.Value) If the commas are real use TextBox3.Value = CLng(TextBox1.Value) + CLng(TextBox2.Value) Mike "Risky Dave" wrote: Hi, I suspect that this is really easy but I haven't been able to figure out the solution. I have a form that holds a couple of numbers in text boxes, eg: TextBox1.Value is 2,000 TextBox2.Value is 12,500 What I want to do is add these two as numbers and display the answer in TexBox3. There will be no further manipulation of the value in TextBox3, so I don't actually care if it stored as a number or as text, so long as it is diaplayed as 14,500 TIA Dave TIA |
Convert text to Long
Many thanks
"Mike H" wrote: Hi, If the commas aren't there you can use TextBox3.Value = Val(TextBox1.Value) + Val(TextBox2.Value) If the commas are real use TextBox3.Value = CLng(TextBox1.Value) + CLng(TextBox2.Value) Mike "Risky Dave" wrote: Hi, I suspect that this is really easy but I haven't been able to figure out the solution. I have a form that holds a couple of numbers in text boxes, eg: TextBox1.Value is 2,000 TextBox2.Value is 12,500 What I want to do is add these two as numbers and display the answer in TexBox3. There will be no further manipulation of the value in TextBox3, so I don't actually care if it stored as a number or as text, so long as it is diaplayed as 14,500 TIA Dave TIA |
Convert text to Long
myval = CLng(TextBox1.Value) + CLng(TextBox2.Value)
TextBox3.Value = Left(myval, Len(myval) - 3) & "," & Right(myval, 3) That last line can be made simpler using the Format function... TextBox3.Value = Format(myval, "0,000") -- Rick (MVP - Excel) |
All times are GMT +1. The time now is 02:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com