Is there a 2005.net version of the vb6 IsNumeric() function.
thanks.
Printable View
Is there a 2005.net version of the vb6 IsNumeric() function.
thanks.
You may still use the One from the MicroSoft.VisualBasic namespace, but I'm strongly recommand to use the Double.TryParse or I thing in 2005 all DataType have is TryParse method.
the IsNumeric in .NET is pure .NET , it's not the vb6 version :)
try running ILDASM to decompile it and you will see that.
there have been previous topics on this if you search this forum :wave:
even if you can't use tryparse (in the case of an integer in .NET 1.1), you can use parse with a try/catch block around it.
not that its a VB6 version so to speak, i think zak was getting at the fact that it is part of the back catalog of functions in the Microsoft.VisualBasic namespace.Quote:
Originally Posted by dynamic_sysop
So if one was to be looking to do something the pure .NET way (meaning it would be coded the same in any of the managed .NET languages) then using some of the other .net methods outside the VB namespace would be a better bet.
Everything in the Microsoft.VisualBasic IS pure .NET code and is managed. Using it is no different than creating your own library to shortcut the functions.... it's what's in the VB6Compatibility namespace that is linked back to the original VB6 libraries (and thusly unmanaged).
-tg
A few different opinions i see. Mmmm, which one to use. thanks for your help.
you can really use either... its all preference.. like I said, stay away from the VisualBasic namespace if you are looking to try to stay language neutral when it comes to the .NET framework, otherwise, use what gets the project working.. one way or the other.
As for the VB6Compatibility you don't have to worry about that too much because you would have to set a reference to it to even use it, there is generally no reason to use that unless you really needed to for some reason
You can use Double.TryParse to parse integer values in .NET 1.1. You simply have to set the "style" argument to Integer. It's a bit easier in .NET 2.0 though, because loads of value types have their own TryParse methods now, including Int32. The advantage of using TryParse over IsNumeric is that you can, if desired, have much more control, including whether negative numbers or currency symbols are permitted. I've said many times, and I think others here are thinking the same, that while there is nothing inherently wrong with Runtime functions, it is preferable to use an alternative from a System-based namespace if one exists. Your code then becomes more readable to developers of other languages and you often remove a redundant method call, given that a great many Runtime functions use the exact same methods and properties that you would in there stead yourself, e.g. MsgBox calls MessageBox.Show anyway so why not just call it yourself. In this case, I don't know for sure but it may well be that IsNumeric calls Double.TryParse too.