Asp conversion function example

Source: Internet
Author: User
Tags chr numeric value
Asp conversion function example
A Variant variable automatically converts its data child types to appropriate data types. in this case, you can use the conversion function to forcibly convert the child type of the data.
Function
The Asc function returns the ANSI character code corresponding to the first letter of the string.
The Chr function returns the character corresponding to the specified ANSI character code.
The Hex function returns a string that represents the hexadecimal numeric value.
The Oct function returns a string that represents the octal value.
The return expression of the CStr function, which has been converted to a string subtype.

The CDate function returns an expression that has been converted to a date subtype.
The CInt function returns an expression that has been converted to an integer subtype.
The CLng function returns an expression that has been converted to a long integer subtype.
The CSng function returns an expression that has been converted to a Single subtype.
The expression returned by the CDbl function. The expression has been converted to the Double subtype.
The CBool function returns an expression that has been converted to a Boolean type.
1. Asc function example
In the following example, Asc returns the ANSI character code of the first letter of each string:
Dim MyNumber
MyNumber = Asc ("A") 'returns 65.
MyNumber = Asc ("a") 'returns 97.
MyNumber = Asc ("Apple") 'returns 65.
2. Chr function example
The following example uses the Chr function to return the characters corresponding to the specified character code:
Dim MyChar
MyChar = Chr (65) 'returns.
MyChar = Chr (97) 'returns.
MyChar = Chr (62) 'return>.
MyChar = Chr (37) 'returns %.
3. Hex function example
The following example uses the Hex function to return the hexadecimal number of a number:
Dim MyHex
MyHex = Hex (5) 'returns 5.
MyHex = Hex (10) 'returns.
MyHex = Hex (459) 'returns 1CB.
4. Oct function example
The following example uses the Oct function to return the octal number of values:
Dim myct
MyOct = Oct (4) 'returns 4.
Myocct = Oct (8) 'returns 10.
MyOct = Oct (459) 'returns 713.
5. CStr function example
<% Num1 = 666 StrWelcome = "welcome" & CStr (num1) & "visitors" %>
CStr forcibly converts the variable num1 from the integer subtype to the string subtype
6. CDate function example
MyDate = "October 19,196 2" 'defines the date.
My1_date = CDate (MyDate) 'is converted to the date data type.
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.