none
Currency Formating RRS feed

  • Question

  • I have a .net Windows application that I developed using Visual Studio 2005 where I use string variables that are being displayed in textboxes. The string variables represent US currency values and I would like them to be formatted as currency so that the $ is displayed to the left of the variable.
    After weeks of searching the internet for a solution, all I have found is related to either a datagrid or a datarepeater of which I am using niether.
    Does anyone have code that will format my string variables into currency for a textbox?
    Thanks.
    Friday, January 29, 2010 2:20 AM

Answers

All replies

  • Hi, robertD517:
         Thanks for posting on this forum.
         Based on your description, it seems that you just need a '$' appear before your string variable for currency value. This could easily be done through string manipulation. If I didn't take it right, could you show some examples of your scenario?

    Thanks,
    Sam.
    Friday, January 29, 2010 3:31 AM
  • Hi,
    Formating currency
    have a look at this link
    http://msdn.microsoft.com/en-us/library/dwhawy9k(VS.71).aspx
    Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
    • Marked as answer by SamAgain Friday, January 29, 2010 9:06 AM
    Friday, January 29, 2010 4:27 AM
  • Just want to say thanks. Although your solution did not work for me, you led me down the right path. I found my solution in the
    ".NET Framework Developer's Guide"
    "Formatting Base Types".
    What I had to do is convert my variables from string to double, then use the ToString method and the currency format string ("C");
            MyStringD = Convert.ToDouble(MyString)
            Dim MyStringNew As String = MyStringD.ToString("C")
            Label.Text = MyStringNew
    Thanks Again
    Saturday, January 30, 2010 8:47 AM