replacements for IsNumeric() and IsDate()

  • Thread starter Thread starter John A Grandy
  • Start date Start date
J

John A Grandy

IsNumeric() and IsDate() are "leftovers" from the VB6 days ...

looking forward, perhaps it would be better not to use them ....

does anyone have suggestions on replacements ?
 
Hi John,

The previous message was to show that something that id in another language
maybe else therefore it is not better.

The visual.basic functions are a full part of the .Net framework.
(That is what Visual.basic extends C#, while you can in C# use operator
overloading and unsafe code as something that is not in Visual.Basic.net)

Do not mix up the visual.basic functions with the visual.basic compatible
part, they are disapearing.
IsNumeric() and IsDate() are "leftovers" from the VB6 days ...
looking forward, perhaps it would be better not to use them ....
does anyone have suggestions on replacements ?

I hope this helps,

Cor
 
* "John A Grandy said:
IsNumeric() and IsDate() are "leftovers" from the VB6 days ...

'Double.TryParse', 'DateTime.ParseExact' or 'DateTime.Parse' + erception
handler. As you can see, there is no direct 1:1 replacement for these
functions. I would still use them because they are valid part of VB.NET
and will remain in the "language" in future releases.
looking forward, perhaps it would be better not to use them ....

I would still use them if their use is appropriate and there is no
simple pendant available in the .NET Framework Class Library.
 
IsNumeric and IsDate are actually core to the VB language runtime rather
than "leftovers". Things that didn't exactly fit into the VB.NET paradigm
but were provided solely for compatibility with old VB code appear in the
Microsoft.VisualBasic.Compatibility namespace, and require a seperate
assembly (DLL) from the normal VB runtime library. That compatibility stuff
is mostly control arrays, old ADO equivalents, and web classes.

For anyone reading this, don't scoff at these language runtime functions
like IsNumeric and IsDate. They are great functions to have as part of a
language runtime. They do not have direct counterparts elsewhere in the
framework, and those who use C# notice the inconvenience of not having them
(though that doesn't mean it isn't possible to do the same with C# - you
just don't get it "for free" as it were). Note that if you look at the
compiled IL for these functions, IsNumeric for example, you will find that
it does a LOT of things above and beyond a simple Double.Parse (which is
available in the base framework) - as an example, IsNumeric also deals
properly with hex strings.

-Rob Teixeira [MVP]
 
Back
Top