IsNumeric to detect whether it is a numeric type of ASP code _ Application Tips

Source: Internet
Author: User

The ASP determines whether is the number usually uses the IsNumeric () function, its function is to judge inside the parameter expression is not the numerical value, the usage: isnumeric (content), if "content" the result of the final operation is a number, then IsNumeric returns True; If expression is a date expression, IsNumeric returns False.

A specific example of whether an ASP is a number:

Copy Code code as follows:

<%
If IsNumeric (content) Then
Response.Write ("is number")
Else
Response.Write ("not number")
End If
%>

Or

Copy Code code as follows:

<%if not IsNumeric (content) Then
Response.Write ("not number")
Else
Response.Write ("is number")
End If
%>

It should be noted, however, that the "value" referred to in IsNumeric not only contains ordinary figures, but also (and 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".

So you should pay attention to the ASP to determine whether the number/value of the IsNumeric content of the final parameter expression results may include the above, if the inclusion of the above situation, IsNumeric will return true.

Copy Code code as follows:

'**************************************************
' function id:0014[detection ID is a numeric type]
' Function name: jcid
' function: Detect if ID is a numeric type
' parameter: paravalue----The ID value being detected
' Return value: Returns an ID value if the number type is not returned 0
'**************************************************
Function jcid (ByVal paravalue)
If (not IsNumeric (Paravalue) or (Trim (paravalue) = "") Then
Jcid=0
Else
Jcid=paravalue
End If
End Function

Related Article

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.