0

I have a problem with a convert.ToDouble and I don't find the answer on the net, stackOverFlow, etc...

I try to convert this string value "7,8" (same pb with another : "4,84232") to double.

Here is my code :

   Dim result As Double
   Dim Line as String = "Test = 4,84232"
   Dim LineArray() As String = Line.Split("="c)

    Select Case LineArray(0).Trim
         Case "Test"
             result = Convert.ToDouble(LineArray(1).Trim)
             'this line return a System.OverflowException: Value was either too large or too small for a Double.
         Case "xxx"
            ...
    End Select 

I don't understand the error "Value was either too large or too small for a Double."

I Try to change decimal caracter ".", return a format error but not this one !!

Can you please help me ? Thanks a lot !

Jeff
  • 59
  • 2
  • 10
  • Works for me. No errors. The comma one returns: "484232.0" The one with a period returns "4.84232". – Keith Jan 29 '15 at 16:26
  • here is the complete trace for me : System.OverflowException: Value was either too large or too small for a Double. at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Double.Parse(String s, NumberStyles style, NumberFormatInfo info) Oops, I forget to say : it's working for me in a pc, not in another. Seems to be a configuration problem, but not the language or decimal point or comma. – Jeff Jan 29 '15 at 16:33
  • For sure this has to do with your regional settings on the computer which doesn't work. If you need this to work for "everyone" then you should probably remove the `,` character and replace it with either nothing or a decimal, depending on what it is actually supposed to represent. – Joe Uhren Jan 29 '15 at 18:07

0 Answers0