Results 1 to 9 of 9

Thread: [RESOLVED] IsNumeric

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    499

    Resolved [RESOLVED] IsNumeric

    Is there a 2005.net version of the vb6 IsNumeric() function.

    thanks.

  2. #2
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: IsNumeric

    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.
    Using VS 2010 on Fw4.0

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142

    Re: IsNumeric

    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
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: IsNumeric

    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.

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: IsNumeric

    Quote Originally Posted by dynamic_sysop
    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
    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.

    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.

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: IsNumeric

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    499

    Re: IsNumeric

    A few different opinions i see. Mmmm, which one to use. thanks for your help.

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: IsNumeric

    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

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] IsNumeric

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width