471,604 Members | 1,543 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,604 software developers and data experts.

Formating money for display in a textbox

I have a textbox that displays money, I cannot find out how to format it so
it displayes like '$123.00' what i get now is '123.00'. Can someone point me
in the right direction?

Thanks in advance!!!
--
Norm Bohana
Nov 27 '05 #1
7 40277
nbohana wrote:
I have a textbox that displays money, I cannot find out how to format
it so it displayes like '$123.00' what i get now is '123.00'. Can
someone point me in the right direction?


myvalue.ToString("C");

http://msdn.microsoft.com/library/en...matstrings.asp
--
Chris Priede

Nov 27 '05 #2
Chris thanks for you help on this problem. I have been working on something
else and now I am back to this problem. The number add up ok but do not
format, what am I missing!! please help.

xnum = double.Parse(lcost); ***** this is passed in *******
ynum = double.Parse(txtServiceCost.Text); ***** this is in the textbox *****
znum = xnum + ynum;
znum.ToString("C");

--
Norm Bohana
"Chris Priede" wrote:
nbohana wrote:
I have a textbox that displays money, I cannot find out how to format
it so it displayes like '$123.00' what i get now is '123.00'. Can
someone point me in the right direction?


myvalue.ToString("C");

http://msdn.microsoft.com/library/en...matstrings.asp
--
Chris Priede

Dec 21 '05 #3
What are you assigning your formatted currency to?

With your code:

xnum = double.Parse(lcost); ***** this is passed in *******
ynum = double.Parse(txtServiceCost.Text); ***** this is in the textbox
*****
znum = xnum + ynum;
txtResult.Text = znum.ToString("C");
ToString() is a method and it returns a string value in the format of a
currency. You have to put that string somewhere though!

Steven Nagy

Dec 21 '05 #4
Steve, I am new to this kind of code, and stuck on stupid. Can you please
give me and example!! Thanks.
--
Norm Bohana
"Steven Nagy" wrote:
What are you assigning your formatted currency to?

With your code:

xnum = double.Parse(lcost); ***** this is passed in *******
ynum = double.Parse(txtServiceCost.Text); ***** this is in the textbox
*****
znum = xnum + ynum;
txtResult.Text = znum.ToString("C");
ToString() is a method and it returns a string value in the format of a
currency. You have to put that string somewhere though!

Steven Nagy

Dec 21 '05 #5
Um, I did in my previous posting... ?

If 'znum' is a double, and 'txtResult' is the text box where you want
to put your formatted result, then you need this line:

txtResult.Text = znum.ToString("C");

Is this what you ment?

Steven Nagy

Dec 22 '05 #6
Thanks Steven!!
--
Norm Bohana
"Steven Nagy" wrote:
Um, I did in my previous posting... ?

If 'znum' is a double, and 'txtResult' is the text box where you want
to put your formatted result, then you need this line:

txtResult.Text = znum.ToString("C");

Is this what you ment?

Steven Nagy

Dec 22 '05 #7
No worries. I'd always help someone with a cool name like 'Norm' !!!

Dec 22 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Polar | last post: by
3 posts views Thread by Tom | last post: by
2 posts views Thread by Alberto | last post: by
4 posts views Thread by djc | last post: by
3 posts views Thread by Tina | last post: by
2 posts views Thread by Dave Prouten | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.