ASP conversion function example
Variant variables generally convert their representative data subtypes into suitable data types, but sometimes, auto-conversion will also cause errors that do not match in data types. At this time, the conversion function can be used to force the subtype of conversion data. .
function
Features
ASC function
Returns the ANSI character code corresponding to the first letter of the string.
CHR function
Returns the character corresponding to the specified ANSI character code
HEX function
Returns a string representing a hexadecimal numeric value.
OCT function
Returns a string representing a digital eight-entered value.
CSTR function
Returns the expression that has been converted to a string subtype.
CDATE function
Returns the expression that this expression has been converted to a date subtype.
CINT function
Returns the expression that this expression has been converted to an integer subtype.
CLNG function
Returns the expression, this expression has been converted to long integer subtype
CSNG function
Returns the expression that has been converted to a Single subtype
CDBL function
Return expression, this expression has been converted to a Double subtype
CBOOL function
Return expression, this expression has been converted to Boolean type
1, ASC function example
In the following example, the ASC returns an ANSI character code of each character letter:
DIM MyNumber
MyNumber = ASC ("a") 'Returns 65.
MyNumber = ASC ("a") 'Returns 97.
MyNumber = ASC ("Apple") 'Returns 65.
2, CHR function example
The following example returns a character corresponding to the specified character code using the CHR function:
DIM MyChar
Mychar = chr (65) 'Returns A.
MyChar = chr (97) 'returns a.
Mychar = chr (62) 'Returns>.
Mychar = chr (37) 'returns%.
3, HEX function example
The following example uses the HEX function to return the number of hexadecimal numbers:
DIM MyHEX
MYHEX = HEX (5) 'Returns 5.
MyHex = HEX (10) 'Returns A.
MYHEX = HEX (459) 'Returns 1CB.
4, OCT function example
The following example uses the OCT function to return the number of eight-input number:
DIM MyOct
MyOct = OCT (4) 'Returns 4.
MyOct = OCT (8) 'returns 10.
MyOct = OCT (459) 'Returns 713.
5, CSTR function example
<% Num1 = 666strwelcome = "Welcome" & CSTR (NUM1) & "Visiter"%>
CSTR converts the variable NUM1 by intestinal sub-type into a character string type
6, CDATE function example
Mydate = "October 19, 1962" 'Defines the date. Myshortdate = cdate (mydate) 'Converts to date data type. MyTime = "4:35:47 PM" 'Defines the time. MyShortTime = CDATE (MyTime) 'Converts to date data types.
7, CINT function example
DIM mydouble, myintmydouble = 2345.5678 'myduble is Double. Myint = CINT (MYDOUBLE) 'Myint contains 2346.8, CLNG function example
Dim myval1, myval2, mylong1, mylong2myval1 = 25427.45: myval2 = 25427.55 'myval1, myval2 is a double precision value. MYLONG1 = Clng (myval1) 'mylong1 25427. Mylong2 = clng (myval2) 'mylong2 contains 25428.
9, CBOOL function example
DIM A, B, CHECKA = 5: b = 5 'initialization variable. Check = CBOOL (a = b) 'check box is True. A = 0 'defines variables. Check = CBOOL (a) 'check box is false.