Download Source Code -How to Convert Whole Numbers to Currency in C#


How to Convert Whole Numbers to Currency in C#

Submitted by: 
Visitors have accessed this post 9 times.

If you find hard to convert whole numbers to currency, this tutorial is right for you. So, in this tutorial, I will teach you how to convert whole numbers to currency in c#. This method has the ability to convert any whole numbers given in a textbox and it will automatically display to another textbox in a currency format in just a click. Let’s begin.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application for c#.

Step 2

Add two labels, two textboxes and a button in the form. After that, design the form just like shown below.
figure 2

Step 3

Double click the button and do the following codes to convert the whole number in a currency format when the button is clicked.

  2. private void button1_Click(object sender, EventArgs e)
  3. {
  5. Decimal currency;
  7. currency = decimal.Parse(textBox1.Text);
  9. if(currency >= 0)
  10. {
  11. textBox2.Text = currency.ToString("##,###.00");
  12. }
  13. else
  14. {
  15. currency = Math.Abs(currency);
  16. textBox2.Text = currency.ToString("##,###.00") + "-";
  17. }
  18. }


figure 3
The complete source code is included. You can download it and run it on your computer.
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.

convert number to decimal
convert number to currency
currency format

Add new comment

(Visited 2 times, 1 visits today)