IsNumeric() IsDate() ...

M

Michael Ramey

Hi,

What are the replacement methods in the .net framework for the old vb
functions such as IsNumeric(), IsDate(), etc...

Thanks
--Michael
 
M

Marina

Those methods are actually still there in
Microsoft.VisualBasic.Compatibility. They were afraid to take them out and
freak out all the VB6 developers. By default VB.NET projects reference this,
so these methods are available.

Other then that, you can use Int32.Parse,Double.Parse,DateTime.Parse, etc
method to check if something fits those data types. There will be an
exception thrown if whatever you are parsing can't be turned into that
particular datatype.
 
C

Chris Gallucci

Hi,
What are the replacement methods in the .net framework for the old vb
functions such as IsNumeric(), IsDate(), etc...

Thanks
--Michael

You might look at Int32.Parse() and friends as well as DateTime.Parse() and
friends.

ChrisG
 
H

Herfried K. Wagner [MVP]

* "Michael Ramey said:
What are the replacement methods in the .net framework for the old vb
functions such as IsNumeric(), IsDate(), etc...

There are no "replacements". These functions don't get "replaced".
They are valid part of VB.NET and there is no reason why they should not
be used any more.

For 'IsNumeric', you can use 'Double.TryParse' at the moment, although
thats not an 1:1 replacement. In .NET 2.0 (Whidbey, 2004) there will be
'TryParse' methods for other numeric datatypes like 'Integer' too. For
'IsDate' you can use 'DateTime.Parse' and/or 'DateTime.ParseExact' + an
exception handler ('Try...Catch').
 
A

Armin Zingler

Marina said:
Those methods are actually still there in
Microsoft.VisualBasic.Compatibility.

Sure? ;-)
They were afraid to take them out and
freak out all the VB6 developers. By default VB.NET projects reference this,
so these methods are available.

No, only the usual VB library is referenced by default, not the
compatibility library that should only be used for upgraded projects.
 
C

Cor [LVP]

No, only the usual VB library is referenced by default, not the
compatibility library that should only be used for upgraded projects.
So they are not standard available?
 
C

Cor

Hi Armin,

Yes but that is not completly clear from your message.

You only say "sure ?" and not that they are normal in the

Microsoft.VisualBasic namespace

Cor
 
A

Armin Zingler

Cor said:
Hi Armin,

Yes but that is not completly clear from your message.

You only say "sure ?" and not that they are normal in the

Microsoft.VisualBasic namespace

After writing "sure?" I think she will see where it actually is.
 
M

Marina

I didn't remember exactly where it was and didn't bother to look it up. My
point was that it was in a DLL created specifically to make VB6 to VB.NET
transition easier.
 
C

Cor

But that is not Marina

That is our point it is a part of the framework

While the compatibly is not.

:)

Cor
 
R

Rob Teixeira [MVP]

Not necessarily true. The VB runtime DLL is the standard VB function
library, and IsDate/IsNumeric are part of that library.
The functionality that has been depreciated and/or was built specifically
for easing migration lives in the Compatibility DLL.
The BIG difference is that the VB function library is not depreciating.
Also, there is *no* direct alternative to these functions in the runtime
library. If you use ILDasm to see this implementation, you will notice that
these functions do a lot more than the Parse() methods available on double
and DateTime. VB's runtime library is a tremendous convenience. Who would
want to keep writing these functions over and over? And more to the point,
if you created your own library for them, it'd be no different.

-Rob Teixeira [MVP]

Marina said:
I didn't remember exactly where it was and didn't bother to look it up. My
point was that it was in a DLL created specifically to make VB6 to VB.NET
transition easier.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top