Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 61605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:20:43+00:00 2026-05-10T18:20:43+00:00

I’m hoping there’s something in the same conceptual space as the old VB6 IsNumeric()

  • 0

I’m hoping there’s something in the same conceptual space as the old VB6 IsNumeric() function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:20:44+00:00Added an answer on May 10, 2026 at 6:20 pm

    2nd October 2020: note that many bare-bones approaches are fraught with subtle bugs (eg. whitespace, implicit partial parsing, radix, coercion of arrays etc.) that many of the answers here fail to take into account. The following implementation might work for you, but note that it does not cater for number separators other than the decimal point ".":

    function isNumeric(str) {   if (typeof str != "string") return false // we only process strings!     return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...          !isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail } 

    To check if a variable (including a string) is a number, check if it is not a number:

    This works regardless of whether the variable content is a string or number.

    isNaN(num)         // returns true if the variable does NOT contain a valid number 

    Examples

    isNaN(123)         // false isNaN('123')       // false isNaN('1e10000')   // false (This translates to Infinity, which is a number) isNaN('foo')       // true isNaN('10px')      // true isNaN('')          // false isNaN(' ')         // false isNaN(false)       // false 

    Of course, you can negate this if you need to. For example, to implement the IsNumeric example you gave:

    function isNumeric(num){   return !isNaN(num) } 

    To convert a string containing a number into a number:

    Only works if the string only contains numeric characters, else it returns NaN.

    +num               // returns the numeric value of the string, or NaN                     // if the string isn't purely numeric characters 

    Examples

    +'12'              // 12 +'12.'             // 12 +'12..'            // NaN +'.12'             // 0.12 +'..12'            // NaN +'foo'             // NaN +'12px'            // NaN 

    To convert a string loosely to a number

    Useful for converting ’12px’ to 12, for example:

    parseInt(num)      // extracts a numeric value from the                     // start of the string, or NaN. 

    Examples

    parseInt('12')     // 12 parseInt('aaa')    // NaN parseInt('12px')   // 12 parseInt('foo2')   // NaN      These last three may parseInt('12a5')   // 12       be different from what parseInt('0x10')   // 16       you expected to see. 

    Floats

    Bear in mind that, unlike +num, parseInt (as the name suggests) will convert a float into an integer by chopping off everything following the decimal point (if you want to use parseInt() because of this behaviour, you’re probably better off using another method instead):

    +'12.345'          // 12.345 parseInt(12.345)   // 12 parseInt('12.345') // 12 

    Empty strings

    Empty strings may be a little counter-intuitive. +num converts empty strings or strings with spaces to zero, and isNaN() assumes the same:

    +''                // 0 +'   '             // 0 isNaN('')          // false isNaN('   ')       // false 

    But parseInt() does not agree:

    parseInt('')       // NaN parseInt('   ')    // NaN 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I would make these two static methods (ExtractZip and AddFileToZip)… May 12, 2026 at 12:59 am
  • Editorial Team
    Editorial Team added an answer When you develop solutions for SharePoint using Visual Studio, there… May 12, 2026 at 12:59 am
  • Editorial Team
    Editorial Team added an answer In Django, the server environment variables are provided as dictionary… May 12, 2026 at 12:59 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.