Environment versions
Network:
Windows 2003 Server
>>That sounds like a gotcha in the VB implicit conversion rules with Option Strict OFF. If you have two overloads (one accepting a string and the other an integer) and attempt to call that function with a decimal value as the parameter then the compiler doesn't know whether it should implicitly convert to a string or an integer (ie which overload to use). You should cast to the type you wish to use prior to the call.
>>(In C# the same construct would give the usual 'invalid argument' error).
>>But I'm not sure why you saw this only at runtime - the compiler should catch it?
>
>That is exactly that. Since I added an overload for a double last night, it started to work.
Because Decimal will implicity widen to Double. You won't lose information but might lose precision. If I worked with VB.NET the first thing I'd do would be to set OPTION STRICT ON. It still allows all the implicit widening conversions but will catch a lot more potential problems at compile time
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only