Function syntax
Len (string | varname) returns the number of characters in the string or the number of bytes required to store a variable.
Trim trim (string) removes spaces before and after the string
Ltrim (string) removes spaces before the string
Rtrim (string) removes spaces after the string
Mid mid (string, start, length) gets the length string starting from the start character of the string. If the third parameter is omitted, it indicates the string starting from the start character to the end of the string.
Left left (string, length) gets the length string from the left side of the string.
Right right (string, length) gets the length string from the right side of the string.
Lcase (string) converts all uppercase letters in the string to lowercase letters.
Ucase (string) converts all uppercase letters in the string to uppercase letters.
Strcomp (string1, string2 [, compare]) returns the comparison result between the string1 string and the string2 string. If the two strings are the same, 0 is returned. If the two strings are less than 1,-1 is returned, if the value is greater than 1, 1 is returned.
Instr (string1, string2 [, compare]) returns the position where the string1 string first appears in the string2 string.
Split split (string1, delimiter [, Count [, start]) Splits a string into one-dimensional arrays based on delimiter. Delimiter is used to identify the substring boundary. If omitted, use space ("") as the separator. Count returns the number of substrings.-1 indicates that all substrings are returned. Start is 1. If it is 0, or the binary comparison is omitted.
Replace Replace (expression, find, replacewith [, compare [, Count [, start]) returns a string, where a specified number of substrings (FIND) replacewith ).
Supplement:
The ASC function extracts the ANSI character code of the first letter of the string.
Usage: result = ASC (string)
The result is the escape code, and the string is any valid string expression. If the string is empty, a real-time error is generated.
The ASCB function extracts the first byte of a string.
Usage: result = ASCB (string)
The result is a byte word class, and the string is any valid string expression. If the string is empty, a real-time error is generated.
The ASCW function extracts the Unicode bytecode of the first letter of the string.
Usage: result = ASCW (string)
Here, result is Unicode, and string is any valid string expression. If the string is empty, a real-time error is generated.
The instr function recognizes the initial position of a mark in a string.
Usage: Newstart = instr ([start,] source, Token [, compare])
Newstart indicates the position of the mark in the string (if not, it is 0). Start indicates the start position of the search, source indicates the string to be searched, and Token indicates the string to be located, compare is a comparison type (0 indicates binary comparison, and 1 indicates case-insensitive text comparison ).
The sort B function is a byte version of instr. It recognizes the first byte position of a mark in a string.
Usage: Newstart = 1_ B ([start,] source, Token [, compare])
Newstart indicates the position of the mark in the first byte of the string (if not, it is 0). Start indicates the start position of the search, source indicates the string to be searched, and Token indicates the string to be located, compare is a comparison type (0 indicates binary comparison, and 1 indicates case-insensitive text comparison ).
The lcase function converts a string to lowercase.
Usage: result = lcase (string)
The result is a lowercase string, and the string is any valid string expression.
The left function extracts a specified number of characters from the start of a string.
Usage: result = left (string, length)
Here, result is a string variable, string is a valid string expression, and length is a numeric expression that represents the number of characters returned.
The leftb function extracts a specified number of bytes from the start of the string.
Usage: result = leftb (string, length)
Here, result is a string variable, string is a valid string expression, and length is a numeric expression that represents the number of extracted bytes.
The LEN function determines the size of the string or the number of characters required to store the variable.
Usage: result = Len (string | varname)
Here, result is the number of characters in the string or the number of bytes required to store the variable. String is any valid string expression, and varname is the variable name.
The lenb Len function determines the size of the string or the number of bytes required to store the variable.
Usage: result = lenb (string | varname)
Result indicates the number of bytes in the string or the number of bytes required to store the variable. String indicates any valid string expression, and varname indicates the variable name.
The ltrim function copies the string and removes the leading space.
Usage: result = ltrim (string)
The result is the string after the space is removed, and the string is a valid string expression to remove the space.
The mid function copies a specified number of characters from a position in the string.
Usage: result = mid (string, start [, length])
Here, result is the result string, string is the expression for copying characters from it, start is the starting position for copying in string, and length is the number of characters to be copied.
The midb mid function copies a specified number of bytes from a certain position in the string.
Usage: result = mid (string, start [, length])
Here, result is the result string, string is the expression for copying bytes from it, start is the starting position for copying in string, and length is the number of bytes to be copied.
The right function extracts a specified number of characters from the end of the string.
Usage: result = right (string, length)
Here, result is a string variable, string is a valid string expression, and length is a numeric expression that represents the number of characters returned.
The rightb function extracts a specified number of bytes from the start of a string.
Usage: result = rightb (string, length)
Here, result is a string variable, string is a valid string expression, and length is a numeric expression that represents the number of extracted bytes.
The rtrim function copies the string and removes trailing spaces.
Usage: result = rtrim (string)
The result is the string after the space is removed, and the string is a valid string expression to remove the space.
The string function constructs strings containing multiple identical characters.
Usage: result = string (number, character)
Here, result is a string variable, number is the length of the returned string, and character is the character code used to construct the returned string.
The TRIM trim function copies the string and removes spaces at the beginning and end of the string.
Usage: result = trim (string)
The result is the string after the space is removed, and the string is a valid string expression to remove the space.
The ucase function converts strings to uppercase.
Usage: result = ucase (string)
The result is an uppercase string, and the string is any valid string expression.
ASP string functions [discussion]
Function Description
Cbool
Convert data to boolean type
Cdate
Data to time type
Cdbl
Convert data to double type
CINT
Data to integer type
Clng
Data to Lang type
ASC
Character to numeric type
CSTR
Numeric to string type
CHR
Numeric to character type
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 corresponding to the first letter of the string.Code.
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.
Mytime = "4:35:47" 'defines the time.
My1_time = cdate (mytime) 'is converted to the date data type.
7. CINT function example
Dim mydouble, Myint
Mydouble = 2345.5678 'mydouble is double.
Myint = CINT (mydouble) 'myint contains 2346.
8. clng function example
Dim myval1, myval2, mylong1, mylong2
Myval1 = 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, check
A = 5: B = 5' initialize the variable.
Check = cbool (A = B) 'check box is set to true.
A = 0' defines the variable.
Check = cbool (a) 'check box is set to false