hi there,
i have a text box in a form to enter a float value.say that the user types in 1234567789.09 it should be formatted and display as 1,234,567,789.09 how can i do this. i am using a text box.
please can someone help me in this or give me some guidence???


thanxxxxx

You could perhaps consider a Masked TextBox.

You could perhaps consider a Masked TextBox.

how can i do it in a mask text box i looked at it there is no such thing in it to format money

myTextBox.Text = myFloatValue.ToString("#,###.00");

Will convert a float to the format you want. For input, set that as the mask in the textbox (not tested).

myTextBox.Text = myFloatValue.ToString("#,###.00");

Will convert a float to the format you want. For input, set that as the mask in the textbox (not tested).

in mask text box the values are printed from left to right, so there will be extra spaces like
the user wants to type
234.90

it'll be like ___,___,234,90_.__

the user has to find the exact spce to type in the number
is there a way to type from right to left

thannxxx

in mask text box the values are printed from left to right, so there will be extra spaces like
the user wants to type
234.90

it'll be like ___,___,234,90_.__

the user has to find the exact spce to type in the number
is there a way to type from right to left

thannxxx

please can anybody help me with this thread


thankxxxx

Try this:

decimal moneyvalue = 1234567890.09m;
string html = String.Format("{0:C}", moneyvalue);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.