VB.Net: String or Double to Currency Format

baabaa_nl used Ask the Experts™
Hi Experts,

I need to convert a double or a string into currency. What is the best method to convert the values that are in a string or in a double  to currency format(Euro with two decimal places).

Also the values should looks like this for example:   €18.025.785,12  

I am very sure that the users using this applications are only use to the above currency format, the decimal points separated with a comma ',' rather than a regular period '.', and the excess digits are separated with a period rather than a comma.

I need this because when I read the currency values from the database I want to make sure that it is represented on the above format on the ListView, DataGridView and Forms.

Also when I send the currency that looks like €108,10 to an Access Database using an SQL statement from a VB.Net application, do I have to convert that to a string or just extract it as a double and set it to the SQL statement?

Thanks in advance.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
try the FormatCurrency() function,e.g
Dim YourString As String = "108,23"
FormatCurrency(YourString, 2, TriState.False, TriState.False, True)

Open in new window

Top Expert 2011
Here is another option:
Dim culture As CultureInfo = CultureInfo.GetCultureInfo("ga") ' ga (Irish)
Dim n As Double = 18025785.12
Dim s As String = "€18,025,785.12"

Console.WriteLine(n.ToString("C", culture)) ' Double to Currency String

Console.WriteLine( Double.Parse(s, NumberStyles.Currency, culture.NumberFormat) ) ' Currency String to Double

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial