Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
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.
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:
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:
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:
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:
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.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.