ASP and JS type conversion function Introduction _ Application Skills

Source: Internet
Author: User

Converts a string to an integer

Asp:

CInt ()--note that only short integer values must be converted to a range of 32768 and 32767, long Integer Applications CLng ()

If you do not enter a plain numeric string or an empty string, a direct 500 error occurs. So you should check for numeric types before entering.

Copy Code code as follows:

Function jcid (ByVal paravalue)
If (not IsNumeric (Paravalue) or (Trim (paravalue) = "") Then
Jcid=0
Else
Jcid=paravalue
End If
End Function

Convert between types to the desired format:

CStr (): Convert to Character
CDate (): Convert to date
CInt (): Convert to Integer
CLNG (): Convert growth integral type long
CBool (): Convert to Logical Boolean
CByte (): Converted to byte byte
CSng (): Convert to single-precision floating-point number single
CDBL (): Convert to double-precision floating-point number double
CCur (): Convert to currency format currency

Javascript:

parseint ()--converts to an integer. Note: You should check the results with the isNaN function after the conversion, and if the input is not a pure numeric string, the result is Nan.

parseint ("abc")//Return NaN.
parseint ("12ABC")//return 12.

Note: parseint ("08") returns 0, with an understanding of 8 in the beginning of 0, and 08 is an illegal string.

parseint ("08", 10) returns 8 because 10 is specified.

<ptml xmlns= "http://www.w3.org/1999/xhtml" > <pead> <title> title page </title> <script language= " JavaScript "> var info = new Array (); Create an Array object info[' name ' = ' John '; Sets an item in the array, noting that the index is a string type info[' age ' = ' 26 '; Sets the second item in the array var i=0; for (var n in info)//traversing each item in the array {i++;//To get the number of elements in the array} alert ("Total" +i+ "element"); Display the total number of elements in an array </script> </pead> <body> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.