Let me accidentally isnumeric () function

Source: Internet
Author: User
Tags expression numeric numeric value
The function is involved in a post in csdn today, to the effect that the IsNumeric () function of the VBS has a problem, and it treats the letter "D" and "D" as numbers.

I did a simple test on the client, and if the letter "D" or "D" were embedded in the number (not the first and the last), such as "2d3", the IsNumeric () The result of the judgment was true! -Is it really a bug? That's ridiculous, isn't it?

I did a cursory check of the VBS reference and MSDN, which did not mention the bug of IsNumeric (). Then I looked very wisely at Aspfaq and finally found the answer:

In VBS, the IsNumeric () function is the actual function of determining whether a parameter expression is a numeric value, and this so-called "value" contains not only ordinary numbers but also (but may not be limited to) the following:

Scientific notation of notation, such as "2e7" and "2d7";
Hexadecimal numbers, such as "&h0a";
Octal number, such as "&6";
The Currency amount expression set under the current region, such as "¥12.44";
The number of parentheses, such as "(34)";
Explicitly specify positive and negative numbers, such as "+2.1" and "2.1";
A numeric string containing commas, such as "12,25".

Not only Vbs,jscript/javascript isNaN () also have similar problems, isnumeric () in T-SQL is the same! We can study it by ourselves.

So, if you're starting to feel a bit uneasy about a program you've written before, then you'll have to implement a function to verify that the expression is a number-safe.

Thank Aspfaq, of course, also thank csdn on the post of friend Zsrui (chassis).



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.