Format Numbers to Currency String in VB.NET

Aug 31, 2010 by d0rr    1 Comment     Posted under: Web Development

I thought it would be helpful to share this piece of simple code

In VB.NET, it is pretty easy to convert a decimal number (say, 12345.6789) to currency format ($12,345.679)

Just convert the number using the lines of code as shown below:

Dim value_int As Integer = 12345.6789 ' original decimal number
Dim digit As Integer = 3 ' to format it to 3 decimal places
Dim value_str As String = value_int.ToString("C" & digit, Globalization.CultureInfo.CreateSpecificCulture("en-US"))

Also check out other cultures available here.



Related Posts with Thumbnails

1 Comment + Add Comment

  • Extremely helpful, despite being posted in the wrong section, haha. Thanks for this great bit of code.

Got anything to say? Go ahead and leave a comment!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>