PC Review


Reply
Thread Tools Rate Thread

Convert text to Long

 
 
Risky Dave
Guest
Posts: n/a
 
      10th Apr 2009
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
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      10th Apr 2009
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

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      10th Apr 2009
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

 
Reply With Quote
 
Risky Dave
Guest
Posts: n/a
 
      10th Apr 2009
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

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      10th Apr 2009
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting block of text takes a long, long, LONG time Nessie Microsoft Word Document Management 1 11th Jun 2009 03:14 PM
RE: Convert Lat/Long to Pixel Family Tree Mike Microsoft C# .NET 0 14th Oct 2008 12:15 PM
Convert to Long from Double that is over 18 digit long from Oracle =?Utf-8?B?Sm9yZGFu?= Microsoft Dot NET Framework 3 2nd Jul 2006 02:49 PM
How do you convert numbers as "text" to values for a long column . =?Utf-8?B?Z2VvZXhjZWw=?= Microsoft Excel Misc 2 27th Feb 2005 04:31 PM
How to convert a DateTime to a long Vicki Carlsen Microsoft C# .NET 3 31st Jul 2003 06:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:19 AM.