Click here to Skip to main content
15,848,451 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have recently bought a new laptop running windows 8. I have installed Visual Studio 2012. I am getting type conversion errors when I should not. Can anyone tell me if this is an installation error for Visual Studio ?


VB
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim n As Double = Convert.ToDouble("256.234")
        Debug.Print(n)
    End Sub
End Class


When I run the code above, I get the following error.

"FormatException was unhandled - input string was not in a correct format."

This makes no sense..
Posted
Updated 20-Jun-13 1:06am
v2
Comments
Prasad Khandekar 20-Jun-13 6:23am    
Hello,

The Convert.ToDouble(string) interprets the value is using formatting conventions of the current thread culture. Please see MSDN documentation (http://msdn.microsoft.com/en-us/library/zh1hkw6k.aspx). Check the regional Settings of your machine and verify the formatting.

Regards,
Hummer463 20-Jun-13 6:40am    
Thank you ! You were right. My regional settings had "," instead of "." for decimals. changed it and now my application works again.
Prasad Khandekar 20-Jun-13 6:44am    
You are welcome. Just posted it as a solution as well.

1 solution

Hello,

The Convert.ToDouble(string) interprets the value is using formatting conventions of the current thread culture. Please see MSDN documentation[^]. Please check the regional Settings of your machine and verify the formatting.

Regards,
 
Share this answer
 

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