Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi experts,

I have one problem with convert string to double.
I have string like this (123456789) and i want to convert it to double like this (123,456,789.00).

Does anyone know how to format like this?

Thanks

TONY
Posted

Hi,

What you want is to convert this string to double and then display it in your format. To achieve this you may try this code:
VB
Private Sub Form1_Load(sender As Object, e As EventArgs)
    Dim strValue As String = "123456789"
    Dim d As Double = 0
    If [Double].TryParse(strValue, d) Then
        MessageBox.Show(d.ToString("0,0.00", CultureInfo.InvariantCulture))
    End If
End Sub
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Aug-12 0:18am    
Right, a 5.
--SA
Turning that string into a double is done with Double.TryParse

However, that other requirement is NOT a double, it's a local representation of that double, in a string, to two DP

Locale dictates grouping, grouping separator and DP character, i.e. that string would be 123.456.789,00 in France

You'd use FormatNumber[^] to get that
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Aug-12 0:18am    
Right, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900