asp type conversion implementation function
abs(number)
Returns the absolute value.
array(arglist)
Create an array.
asc(string)
Returns the ANSI code of the first character of the string.
atn(number)
Returns the arcsine value.
cbool (expression)
Convert to boolean data type variable.
cbyte (expression)
Convert to byte data type variable.
ccur (expression)
Convert to currency data type variable.
cdate (expression)
Convert to date data type variable.
cdbl (expression)
Convert to double data type variable.
chr(charcode)
Convert ansi code into corresponding keyboard characters.
cint (expression)
Convert to integer data type variable.
clng (expression)
Convert to long data type variable.
createobject(servername.typename)
Create an automatic object.
csng (expression)
Convert to single data type variable.
cstr (expression)
Convert to string data type variable.
date
The return time depends on the system used.
dateadd(interval,number,date)
Adds the specified time interval to the date object. The parameter interval accepts the values shown in the table below.
set value
describe
yyyy
Year
q
quarter
m
month
y
Day of the year
d
sky
w
day of week
ww
the first few weeks of the year
h
Hour
m
minute
seconds
datediff(interval,date1,date2])
Returns the interval between two dates. For the values of firstdayofweek and firstweekofyear, please refer to the Date and Time Constants section below. The interval parameter accepts the values shown in the following table.
set value
describe
yyyy
Year
q
quarter
m
month
y
Day of the year
d
sky
w
day of week
ww
the first few weeks of the year
h
Hour
m
minute
seconds
datepart(interval, date])
Returns the specified part of the date object. For the values of firstdayofweek and firstweekofyear, please refer to the Date and Time Constants section below. The interval parameter accepts the values shown in the following table.
set value
describe
yyyy
Year
q
quarter
m
month
y
Day of the year
d
sky
w
day of week
ww
the first few weeks of the year
h
Hour
m
minute
seconds
dateerial(year,month,day)
Convert to date data subtype variant value.
datevalue(date)
Convert to date data subtype variant value.
day(date)
Returns the number of the day in a month based on the parameter date.
exp(number)
Returns the value of e raised to the power of number.
filter(inputstrings,value])
Create a new array based on filter criteria. For the value of compare, please refer to the section on comparing constants later.
fix(number)
Convert to an integer (for negative numbers, only do not round).
formatcurrency(expression]]])
Formatted into currency form. For the values of includeleadingdigit, useparensfornegativenumbers and groupdigit, please refer to the following section on three-state constants.
formatdatetime(date)
Formatted output of date and time. For the value of namedformat, please refer to the section on date format constants later.
formatnumber(expression]]])
Format the number. For the values of includeleadingdigit, useparensfornegativenumbers and groupdigit, please refer to the following section on three-state constants.
formatpercent(expression]]])
Format percentiles. For the values of includeleadingdigit, useparensfornegativenumbers and groupdigit, please refer to the following section on three-state constants.
getobject()
Returns the specified dynamic object from the specified file.
hex(number)
Returns the hexadecimal value of number.
hour(time)
Returns the hour based on the value of the time parameter.
inputbox(prompt)
Displays a temporary input box and returns the user's input.
instr(string1,string2)
Returns the position of the first occurrence of string string2 in string string1. For the value of compare, please refer to the later section on comparison constants.
instrrev(string1,string2])
Returns the position of the last occurrence of string string2 in string string1. For the value of compare, please refer to the later section on comparison constants.
int(number)
Returns an integer (negative numbers are only rounded).
isarray(varname)
Determines whether the variable is an array.
isdate(expression)
Determine whether the expression expression can be converted into date format.
isempty(varname)
Determine whether the variable has been initialized.
isnull(expression)
Determines whether expression expression is empty.
isnumberic(expression)
Determines whether the result of expression expression is a number.
isobject(expression)
Determines whether expression expression is an automatic object.
join(list,)
Concatenates all substrings in an array, using the delimiter set by the value of delimiterd.
lbound(arrayname)
Returns the lowest bound of a dimension of an array. In the current version of VBScript, this function always returns the value 0.
lcase(string)
Format with lowercase characters.
left(string,length)
Returns the left part of a string of specified length.
len(string|varname)
Returns the length of the string string or the length in bytes of the variable varname.
loadpicture(pitcurename)
Load an image object.
log(number)
Returns the natural logarithm of number.
ltrim(string)
Remove extra spaces to the left of string string.
mid(strin,start)
Returns a substring of a string of specified length.
minute(time)
Returns the value of minutes based on the value of parameter time.
month(date)
Returns the month as a number.
monthname(month)
Returns the month represented by name.
msgbox(prompt)
Displays a message box that asks the user to select a button and returns a value indicating the user's choice. For the button value and return value, please refer to the message box constants section later.
now
Returns the current date and time according to the system.
oct(number)
Returns the octal value of number.
replace(expression,find,replacewith]])
Replaces the specified substring find with the specified substring replacewith the specified number of times. For the value of parameter compare, please refer to the section on comparing constants later.
right(string,length)
Returns the right substring of a string of specified length.
rnd()
Generate a random number.
round(number)
Rounds a number based on a specified number of decimal digits.
rtrim(string)
Remove extra spaces to the right of string string.
scriptengine
Returns the name of the scripting language used.
scriptenginebuildversion
Returns the scripting engine version used.
scriptenginemaorversion
Returns the major version number of the scripting engine being used.
second(time)
Returns the second of the minute based on the value of the parameter time.
sgn(number)
Returns the sign of number.
sin(number)
Returns the sine of number number.
space(number)
Creates a string with the specified number of spaces.
split(expression]])
Split and convert a string into an array. For the value of compare, please refer to the section on comparing constants later.
sqr(number)
Returns the square root of number number.
strcomp(string1,string2)
String comparison. For the value of compare, please refer to the section on comparing constants later.
strreverse(string1)
Reverse the string string1.
string(number,character)
Create a string with number characters.
tan(number)
Returns the tangent of number.
time
Returns the current time according to the system.
timeserial(hour,minute,second)
Return the date variable body.
timevalue(time)
Returns the date variable body containing the time.
trim(string)
Remove extra spaces from both sides of the string string.
typename(varname)
Returns the name of the subtype. For the return value, please refer to the section on variable type constants later.
ubound(arrayname)
Returns the upper bound of a certain dimension of the array. The default dimension is the first dimension.
ucase(string)
Format a string string with uppercase letters.
vartype(varname)
Returns the value of the subtype. For the return value, please refer to the section on variable type constants later.
weekday(date,)
Returns the day of the week as a number. For the value of the parameter firstdayofweek, please refer to the section on variable type constants later.
weekdayname(weekday,abbreviate,firstdayofweek)
Returns the day of the week as a name. For the value of the parameter firstdayofweek, please refer to the section on variable type constants later.
year(date)
Returns the year based on the parameter date.
Waiting for publication on 2008-2-25 17:04
Some examples and explanations
IsNumeric()
Function to determine whether an object is a number, | Boolean value.
ExpressionIsNumeric(expression)
Example: <%
I = 345
response.write IsNumeric(I)
%>
| Result: True
Even if a number is enclosed in quotation marks, ASP still considers it to be a number.
asp type conversion implementation function
IsObject()
Function to determine whether an object is an object, | Boolean value.
expressionIsObject(expression)
Example: <%
Set con = Server.CreateObject(ADODB.Connection)
response.write IsObject(con)
%>
| Result: True
Lbound()
Function | Specifies the smallest available subscript for an array dimension.
Expression Lbound(arrayname [, dimension])
Example: <%
I = Array(Monday,Tuesday,Wednesday)
response.write Lbound(I)
%>
| Result: 0
Lcase()
function | lowercase form of string
expressionLcase(string)
Example: <%
strTest = This is a test!
response.write Lcase(strTest)
%>
| Result: this is a test!
Left()
Function | Characters before the length character on the left side of the string (including the length character).
ExpressionLeft(string, length)
Example: <%
strTest = This is a test!
response.writeLeft(strTest, 3)
%>
| Result: Thi
Len()
Function | The length of a string.
Expression Len(string | varName)
Example: <%
strTest = This is a test!
response.write Len(strTest)
%>
| Result: 15
Ltrim()
The function removes spaces on the left side of a string.
expressionLtrim(string)
Example: <%
strTest = This is a test!
response.write Ltrim(strTest)
%>
| Result: This is a test!
Mid()
Function | String of specific length (starting from start, length is length).
Expression Mid(string, start [, length])
Example: <%
strTest = This is a test! Today is Monday.
response.write Mid(strTest, 17, 5)
%>
| Result: Today
Minute()
Function | Minutes of time.
ExpressionMinute(time)
Example: <%=Minute(#12:45:32 PM#)%>
| Result: 45
Month()
function | date.
ExpressionMonth(date)
Example: <%=Month(#08/04/99#)%>
| Result: 8
MonthName()
Function | Specify month
Expression MonthName(month, [, Abb])
Example: <%=MonthName(Month(#08/04/99#))%>
| Result: August
Now()
function | system time
expressionNow()
Example: <%=Now%>
| Result: 9/9/00 9:30:16 AM
Right()
Function | Characters before the length character on the right side of the string (including the length character).
ExpressionRight(string, length)
Example: <%
strTest = This is an test!
response.write Right(strTest, 3)
%>
| Result: st!
Rnd()
The function generates a random number.
Expression Rnd [(number)]
Example: <%
Randomize()
response.write RND()
%>
| Result: any number between 0 and 1
Waiting for publication on 2008-2-25 17:08
instr search index function
instr function
expression:
InStr([start, ]string1, string2[, compare])
describe:
start
Optional parameters. For a numeric expression, sets the starting point for each search. If omitted, starts at the first character position. If start contains Null, an error will occur. If the compare parameter is specified, the start parameter must be present.
string1
Required parameters. Accepts a string expression to search for.
string2
Required parameters. The string expression to be searched for.
Compare
Optional parameters. Specify string comparisons. If compare is Null, an error will occur. If compare is omitted, the setting of Option Compare determines the type of comparison.
The compare parameter is set to:
constant
value
describe
vbUseCompareOption
-1
Use the Option Compare statement setting to perform a comparison.
vbBinaryCompare
0
Perform a binary comparison.
vbTextCompare
1
Perform a textual comparison.
vbDatabaseCompare
2
For Microsoft Access only, performs a comparison based on information in the database.
return value
Returns 0, 1, 2, -1 or Null, etc.
exception/error
none
DescriptionInStr([start, ]string1, string2[, compare])
Returns the first occurrence of a specified string within another string. In the string string1, search for string2 starting from start. When start is omitted, search from the beginning of string1. When not found, the function value is 0.
if
InStrreturn
string1 is zero length
0
string1 is Null
Null
string2 is zero length
Start
string2 is Null
Null
string2 not found
0
Find string2 in string1
location found
start > string2
0
Example
This example uses the InStr function to find the first occurrence of a string within another string.
Dim SearchString, SearchChar, MyPos
SearchString =XXpXXpXXPXXP ' The string being searched.
SearchChar = P ' To search for the string P.
' Starting from the fourth character, search by text comparison. The return value is 6 (lowercase p).
' Lowercase p and uppercase P are the same under text comparison.
MyPos = Instr(4, SearchString, SearchChar, 1)
' Starting from the first character, search using binary comparison. The return value is 9 (capital P).
' Lowercase p and uppercase P are different in binary comparison.
MyPos = Instr(1, SearchString, SearchChar, 0)
'The default comparison method is binary comparison (the last parameter can be omitted).
MyPos = Instr(SearchString, SearchChar) ' Return 9.
MyPos = Instr(1, SearchString, W) ' Return 0.