ASP Series Function Encyclopedia

Source: Internet
Author: User
Tags constant empty expression numeric value split time interval trim valid
ASP function Encyclopedia
ASP functions are similar to VBScript, and here are some common functions
 
Array ()
 
function returns an array of
 
Expression Array (list)
 
Allow data types: characters, numbers can
 
Example: <%
 
Dim MyArray ()
 
For i = 1 to 7
 
Redim Preserve myarray (i)
 
MyArray (i) = WeekdayName (i)
 
Next
 
%>
 
Return result: An array containing 7 elements was established myarray
 
MyArray ("Sunday", "Monday", ...) "Saturday")
 
 
CInt ()
 
function converts an expression to a numeric type
 
Expression CInt (expression)
 
Allow data type: Any valid character can be
 
Example: <%
 
F = "234"
 
Response.Write CINT (f) + 2
 
%>
 
return Result: 236
 
The conversion character "234" is the number "234" and returns a value of 0 if the string is empty
 
 
CreateObject ()
 
function to establish and return an instance of a registered ActiveX component.
 
Expression CreateObject (objname)
 
Allow data type: objname is the name of any valid, registered ActiveX component.
 
Example: <%
 
Set con = Server.CreateObject ("ADODB.") Connection ")
 
%>
 
 
CSTR ()
 
function to convert an expression to a string.
 
Expression of CStr (expression)
 
Allow data type: expression is any valid expression.
 
Example: <%
 
s = 3 + 2
 
Response.Write "The return result is:" & CStr (s)
 
%>
 
Return Result: Converts the number "5" to the character "5".
 
 
Date ()
 
function to return the current system date.
 
An expression Date ()
 
Allow data type: None.
 
Example: <%=Date%>
 
return Result: 9/9/00
 
 
DATEADD ()
 
The function returns a date that has been changed.
 
Expression DateAdd (timeinterval,number,date)
 
Allow data type:
TimeInterval is the time interval to add;
Number is amount of time intervals to add;
And date is the starting date.
 
Example: <%
 
currentdate = #9/9/00#
 
Newdate = DateAdd ("M", 3,currentdate)
 
Response.Write Newdate
 
%>
 
 
<%
 
currentdate = #12:34:45 pm#
 
Newdate = DATEADD ("h", 3,currentdate)
 
Response.Write Newdate
 
%>
 
return Result: 9/9/00
 
3:34:45 PM
 
"M" = "month";
 
"D" = "Day";
 
If currentdate is in the time format then,
 
"H" = "Hour";
 
"S" = "second";
 
 
DateDiff ()
 
function returns the difference between two dates.
 
Expression DateDiff (Timeinterval,date1,date2 [, FirstDayOfWeek [, FirstWeekOfYear]])
 
Allow data type: TimeInterval represents a type of time separated, such as "M" for "month".
 
Example: <%
 
FromDate = #9/9/00#
 
ToDate = #1/1/2000#
 
Response.Write "There are" & _
 
DateDiff ("D", Fromdate,todate) & _
 
"Millenium from 9/9/00."
 
%>
 
Return result: There are 150 days from 9/9/00 to 2000.
 
 
Day ()
 
function returns the day ordinal of a one-month period.
 
Expression Day (date)
 
Allow data type: Date is any valid day.
 
Example: <%=day (#9/9/00#)%>
 
Return Result: 4
 
 
FormatCurrency ()
 
function returns an expression that has been formatted as a currency value
 
Expression FormatCurrency (Expression [, Digit [, Leadingdigit [, Paren [, Groupdigit]]]
 
Allow data type: Digit indicates the number of digits displayed to the right of the decimal point. The default value is-1, which indicates that the computer's locale is being used; Leadingdigit a three-state constant that indicates whether to display 0 of the decimal point in the front. Example: <%=formatcurrency (34.3456)%>
 
return Result: $34.35
 
 
FormatDateTime ()
 
function returns an expression that has been formatted as a date or time
 
Expression FormatDateTime (Date, [, NamedFormat])
 
Allow data type: NamedFormat indicates the value of the date/time format used, and if omitted, use Vbgeneraldate.
 
Example: <%=formatdatetime ("09/9/00", vbLongDate)%>
 
Return results: Sunday, September 09, 2000
 
 
FormatNumber ()
 
function returns an expression that has been formatted as a numeric value.
 
Expression FormatNumber (Expression [, Digit [, Leadingdigit [, Paren [, Groupdigit]]]
 
Allow data type: Digit indicates the number of digits displayed to the right of the decimal point. The default value is-1, which indicates that the computer's locale is being used.; Leadingdigit I indicates the number of digits displayed to the right of the decimal point. The default value is-1, which indicates that the computer's locale is being used.; Paren indicates the number of digits displayed to the right of the decimal point. The default value is-1, which indicates that the computer's locale is being used.; Groupdigit I indicates the number of digits displayed to the right of the decimal point. The default value is-1, which indicates that the computer's locale is being used ...
 
Example: <%=formatnumber (45.324567, 3)%>
 
return Result: 45.325
 
 
FormatPercent ()
 
function returns an expression that has been formatted as a percentage of trailing% symbols (multiplied by 100). (%)
 
Expression formatpercent (Expression [, Digit [, Leadingdigit [, Paren [, Groupdigit]]]
 
Allow data type: Ditto.
 
Example: <%=formatpercent (0.45267, 3)%>
 
return Result: 45.267%
 
 
Hour ()
 
function returns the number of hours at 24 o'clock.
 
Expression Hour (Time)
 
Allow data type:
 
Example: <%=hour (#4:45:34 pm#)%>
 
return Result: 16
 
(Hour has been converted to 24-hour system)
 
 
Instr ()
 
function returns the position of the first occurrence of a character or string in another string.
 
Expression Instr ([Start,] strtobesearched, strsearchfor [, compare])
 
Allow data type: Start is the starting value for the search, strtobesearched accept the search string strsearchfor the character to search for. Compare comparison method (see ASP constants in detail)
 
Example: <%
 
StrText = "This is a test!!"
 
pos = Instr (StrText, "a")
 
Response.Write Pos
 
%>
 
Return Result: 9
 
 
InStrRev ()
 
Function ditto, just from the last search of the string
 
Expression InStrRev ([Start,] strtobesearched, strsearchfor [, compare])
 
Allow data type: Ditto.
 
Example: <%
 
StrText = "This is a test!!"
 
pos = InStrRev (StrText, "s")
 
Response.Write Pos
 
%>
 
return Result: 13
 
 
 
Int ()
 
function returns the numeric type, not rounded.
 
Expression Int (number)
 
Allow data type:
 
Example: <%=int (32.89)%>
 
Return Result: 32
 
 
IsArray ()
 
function to determine whether an object is an array and returns a Boolean value.
 
Expression IsArray (name)
 
Example: <%
 
Strtest = "test!"
 
Response.Write IsArray (Strtest)
 
%>
 
return Result: False
 
 
IsDate ()
 
function to determine whether an object is a date and return a Boolean value
 
Expression IsDate (expression)
 
Example: <%
 
Strtest = "9/4/2000"
 
Response.Write IsDate (Strtest)
 
%>
 
return Result: True
 
 
IsEmpty ()
 
function to determine whether an object is initialized and returns a Boolean value.
 
Expression IsEmpty (expression)
 
Example: <%
 
Dim I
 
Response.Write IsEmpty (i)
 
%>
 
return Result: True
 
 
IsNull ()
 
function to determine whether an object is empty and returns a Boolean value.
 
Expression IsNull (expression)
 
Example: <%
 
Dim I
 
Response.Write IsNull (i)
 
%>
return Result: False
 
 
IsNumeric ()
 
function to determine whether an object is a number and returns a Boolean value.
 
Expression isnumeric (expression)
 
Example: <%
 
i = "345"
 
Response.Write IsNumeric (i)
 
%>
 
return Result: True
 
Even if the number is quoted, the ASP thinks it is a number.
 
 
IsObject ()
 
function to determine whether an object is an object and return a Boolean value.
 
Expression IsObject (expression)
 
Example: <%
 
Set con = Server.CreateObject ("ADODB.") Connection ")
 
Response.Write IsObject (Con)
 
%>
 
return Result: True
 
 
LBound ()
 
function returns the smallest available subscript for the specified array dimension.
 
Expression Lbound (arrayname [, Dimension])
 
Example: <%
 
i = Array ("Monday", "Tuesday", "Wednesday")
 
Response.Write LBound (i)
 
%>
 
Return Result: 0
 
 
LCase ()
 
function returns the lowercase form of a string
 
Expression Lcase (String)
 
Example: <%
 
Strtest = "This is a test!"
 
Response.Write LCase (Strtest)
 
%>
 
Returned result: This is a test!
 
 
Left ()
 
The function returns the previous character (including the length character) of the length of the character on the left of the string.
 
Expression left (string, length)
 
Example: <%
 
Strtest = "This is a test!"
 
Response.Write Left (Strtest, 3)
 
%>
 
return Result: Thi
 
 
Len ()
 
function to return the length of the string.
 
Expression Len (String | varName)
 
Example: <%
 
Strtest = "This is a test!"
 
Response.Write Len (Strtest)
 
%>
 
return Result: 15
 
 
LTrim ()
 
function to remove the space on the left side of the string.
 
Expression LTrim (String)
 
Example: <%
 
Strtest = "This is a test!"
 
Response.Write LTrim (Strtest)
 
%>
 
Returned result: This is a test!
 
 
Mid ()
 
The function returns a string of a specific length, from start to length.
 
Expression Mid (string, start [, length])
 
Example: <%
 
Strtest = "This is a test! The Today is Monday.
 
Response.Write Mid (Strtest, 17, 5)
 
%>
 
Return Result: Today
 
 
Minute ()
 
The minute the function returns time.
 
Expression Minute (Time)
 
Example: <%=minute (#12:45:32 pm#)%>
 
return Result: 45
 
 
Month ()
 
function returns the date.
 
Expression Month (date)
 
Example: <%=month (#08/04/99#)%>
 
Return Result: 8
 
 
MonthName ()
 
function returns the specified month
 
Expression monthname (month, [, ABB])
 
Example: <%=monthname (Month (#08/04/99#))%>
 
return Result: August
 
 
Now ()
 
function returns the system time
 
Expression now ()
 
Example: <%=Now%>
 
Return results: 9/9/00 9:30:16 AM
 
 
Right ()
 
function returns the previous character (with length characters) of the length character on the right of the string.
 
Expression right (string, length)
 
Example: <%
 
Strtest = "This is a test!"
 
Response.Write Right (strtest, 3)
 
%>
 
return Result: st!
 
 
Rnd ()
 
function to produce a random number.
 
Expression Rnd [(number)]
 
Example: <%
 
Randomize ()
Rnd ()
 
function to produce a random number.
 
Expression Rnd [(number)]
 
Example: <%
 
Randomize ()
Response.Write RND ()
 
%>
 
Return Result: Any number between 0 and 1
 
 
Round ()
 
function returns a value that is rounded by a specified number of digits.
 
Expression Round (expression [, numright])
 
Example: <%
 
i = 32.45678
 
Response.Write Round (i)
 
%>
 
Return Result: 32
 
 
Rtrim ()
 
function to remove the string to the right of the string.
 
Expression Rtrim (String)
 
Example: <%
 
Strtest = "This is a test!!"
 
Response.Write RTrim (Strtest)
 
%>
 
Returned result: This is a test!!
 
 
Split ()
 
function splits a string and returns the result of the split
 
Expression Split (S[,d])
 
Example: <%v= Split (A,B,C)
 
For i = 0 to UBound (V)
 
Response.Write V (i)
 
Next
 
%>
 
Return result: A B C
 
 
Second ()
 
function returns a second.
 
Expression Second (Time)
 
Example: <%=second (#12:34:28 pm#)%>
 
return Result: 28
 
 
StrReverse ()
 
Function back-row a string
 
Expression StrReverse (String)
 
Example: <%
 
Strtest = "This is a test!!"
 
Response.Write StrReverse (Strtest)
 
%>
 
Return the result:!! Tset a Si siht
 
 
Time ()
 
function to return the system time.
 
Expression time ()
 
Example: <%=Time%>
 
Return results: 9:58:28 AM
 
 
Trim ()
 
function to remove a space around a string.
 
Expression Trim (String)
 
Example: <%
 
Strtest = "This is a test!!"
 
Response.Write Trim (Strtest)
 
%>
 
Returned result: This is a test!!
 
 
UBound ()
 
function returns the maximum available subscript for the specified array dimension.
 
Expression Ubound (arrayname [, Dimension])
 
Example: <%
 
i = Array ("Monday", "Tuesday", "Wednesday")
 
Response.Write UBound (i)
 
%>
 
return Result: 2
 
 
UCase ()
 
function to return the uppercase form of a string.
 
Expression UCase (String)
 
Allow data type:
 
Example: <%
 
Strtest = "This is a test!!"
 
Response.Write UCase (Strtest)
 
%>
 
Returned result: This is A test!!
 
 
VarType ()
 
function returns a value indicating a variable quantum type
 
Expression VarType (varName)
 
Example: <%
 
i = 3
 
Response.Write VarType (i)
 
%>
 
Return Result: 2 (number) See "ASP Constant"
 
 
Weekday ()
 
function returns the day ordinal of a week.
 
Expression Weekday (date [, FirstDayOfWeek])
 
Example: <%
 
D = #9/9/00#
 
Response.Write Weekday (d)
 
%>
 
Returned results: 4 (Wednesday)
 
 
WeekdayName ()
 
The function returns the name of the day of the week.
 
Expression WeekdayName (weekday [, ABB [, FirstDayOfWeek]])
 
Example: <%
 
D = #9/9/00#
 
Response.Write WeekdayName (Weekday (d))
 
%>
 
return Result: Wednesday
 
 
Year ()
 
function to return the current year.
 
Expression year (date)
 
Example: <%=year (#9/9/00#)%>
 
Return Result: 1999

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.