Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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)
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert long column to rows Excelchallenged Excel Discussion (Misc queries) 3 March 17th 09 04:53 PM
How do I convert Easting/ Northing GPS coordinates into Lat/Long? Stacey Excel Discussion (Misc queries) 1 June 12th 07 03:58 AM
Convert multiple columns into one long row Access Joe Excel Discussion (Misc queries) 1 October 25th 06 02:13 PM
Convert rows to one single long column? Spalding Excel Discussion (Misc queries) 2 November 21st 05 01:39 PM
How do you convert numbers as "text" to values for a long column . geoexcel Excel Discussion (Misc queries) 2 February 27th 05 04:31 PM


All times are GMT +1. The time now is 02:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"