ASP's function Details-1

Source: Internet
Author: User
Tags date format array empty expression numeric value string time interval
function | Array ()
FUNCTION: Returns an array
Syntax:array (list)
ARGUMENTS: Characters, numbers can be
EXAMPLE: <%
Dim MyArray ()
For i = 1 to 7
Redim Preserve myarray (i)
MyArray (i) = WeekdayName (i)
Next
%>
Result: An array containing 7 elements was created MyArray
MyArray ("Sunday", "Monday", ...) "Saturday")

CInt ()
FUNCTION: Converts an expression to a numeric type
Syntax:cint (expression)
ARGUMENTS: Any valid character can be
EXAMPLE: <%
F = "234"
Response.Write CINT (f) + 2
%>
result:236
The conversion character "234" is the number "234" and returns a value of 0 if the string is empty

CreateObject ()
FUNCTION: Establishes and returns an instance of a registered ActiveX component.
Syntax:createobject (objname)
Arguments:objname is the name of any valid, registered ActiveX component.
EXAMPLE: <%
Set con = Server.CreateObject ("ADODB.") Connection ")
%>
Result:

CStr ()
FUNCTION: Converts an expression to a string.
SYNTAX:CSTR (expression)
Arguments:expression is any valid expression.
EXAMPLE: <%
s = 3 + 2
Response.Write "The result is:" & CStr (s)
%>
Result: Converts the number "5" to the character "5".

Date ()
FUNCTION: Returns the current system date.
Syntax:date ()
Arguments:none.
EXAMPLE: <%=Date%>
Result:8/4/99

DateAdd ()
FUNCTION: Returns a date that has been changed.
Syntax:dateadd (Timeinterval,number,date)
Arguments:timeinterval is the time interval to add; Number is amount of time intervals to add; And date is the starting date.
EXAMPLE: <%
currentdate = #8/4/99#
Newdate = DateAdd ("M", 3,currentdate)
Response.Write Newdate
%>

<%
currentdate = #12:34:45 pm#
Newdate = DATEADD ("h", 3,currentdate)
Response.Write Newdate
%>
Result:11/4/99
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.
Syntax:datediff (Timeinterval,date1,date2 [, FirstDayOfWeek [, firstweekofyear>>)
The arguments:timeinterval represents the type of time separated, as "M" means "month."
EXAMPLE: <%
FromDate = #8/4/99#
ToDate = #1/1/2000#
Response.Write "There are" & _
DateDiff ("D", Fromdate,todate) & _
"Millenium from 8/4/99."
%>
Result: There are 150 days from 8/4/99 to 2000.

Day ()
FUNCTION: Returns the day ordinal of a one-month period.
Syntax:day (date)
Arguments:date is any valid date.
EXAMPLE: <%=day (#8/4/99#)%>
Result:4

FormatCurrency ()
FUNCTION: Returns an expression that has been formatted as a currency value
Syntax:formatcurrency (Expression [, Digit [, Leadingdigit [, Paren [, groupdigit>>>>)
Arguments: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)%>
Result: $34.35

FormatDateTime ()
FUNCTION: Returns an expression that has been formatted as a date or time
Syntax:formatdatetime (Date, [, namedformat>)
Arguments:namedformat indicates the value of the date/time format used, and if omitted, uses Vbgeneraldate.
EXAMPLE: <%=formatdatetime ("08/4/99", vbLongDate)%>
Result:wednesday, August 04, 1999

FormatNumber ()
FUNCTION: Returns an expression that has been formatted as a numeric value.
Syntax:formatnumber (Expression [, Digit [, Leadingdigit [, Paren [, groupdigit>>>>)
Arguments: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)%>
result:45.325

formatpercent ()
FUNCTION: Returns an expression that has been formatted as a percentage of the trailing% symbol (multiplied by 100). (%)
Syntax:formatpercent (Expression [, Digit [, Leadingdigit [, Paren [, groupdigit>>>>)
ARGUMENTS: Ditto.
EXAMPLE: <%=formatpercent (0.45267, 3)%>
result:45.267%

Hour ()
FUNCTION: Returns the number of hours at 24 o'clock.
Syntax:hour (Time)
ARGUMENTS:
EXAMPLE: <%=hour (#4:45:34 pm#)%>
Result:16
(Hour has been converted to 24-hour system)

Instr ()
FUNCTION: Returns the position in which a character or string appears for the first time in another string.
Syntax:instr ([Start, > Strtobesearched, strSearchFor [, compare>)
Arguments:start is the starting value for the search, strtobesearched accept the search string strsearchfor the character compare to search (see ASP constants in detail)
EXAMPLE: <%
StrText = "This is a test!!"
pos = Instr (StrText, "a")
Response.Write Pos
%>
Result:9

InStrRev ()
FUNCTION: Ditto, just from the last search of the string
Syntax:instrrev ([Start, > Strtobesearched, strSearchFor [, compare>)
ARGUMENTS: Ditto.
EXAMPLE: <%
StrText = "This is a test!!"
pos = InStrRev (StrText, "s")
Response.Write Pos
%>
Result:13

Int ()
FUNCTION: Returns a numeric type, not rounded.
Syntax:int (number)
ARGUMENTS:
EXAMPLE: <%=int (32.89)%>
Result:32

IsArray ()
FUNCTION: Determines whether an object is an array and returns a Boolean value.
Syntax:isarray (name)
ARGUMENTS:
EXAMPLE: <%
Strtest = "test!"
Response.Write IsArray (Strtest)
%>
Result:false

IsDate ()
FUNCTION: Determines whether an object is a date and returns a Boolean value
Syntax:isdate (expression)
Arguments:expression is any valid expression.
EXAMPLE: <%
Strtest = "8/4/99"
Response.Write IsDate (Strtest)
%>
Result:true

IsEmpty ()
FUNCTION: Determines whether an object is initialized and returns a Boolean value.
Syntax:isempty (expression)
ARGUMENTS:
EXAMPLE: <%
Dim I
Response.Write IsEmpty (i)
%>
Result:true

IsNull ()
FUNCTION: Determines whether an object is empty and returns a Boolean value.
Syntax:isnull (expression)
ARGUMENTS:
EXAMPLE: <%
Dim I
Response.Write IsNull (i)
%>
Result:false

IsNumeric ()
FUNCTION: Determines whether an object is a number and returns a Boolean value.
Syntax:isnumeric (expression)
ARGUMENTS:
EXAMPLE: <%
i = "345"
Response.Write IsNumeric (i)
%>
Result:true
Even if the number is quoted, the ASP thinks it is a number.

IsObject ()
FUNCTION: Determines whether an object is an object and returns a Boolean value.
Syntax:isobject (expression)
ARGUMENTS:
EXAMPLE: <%
Set con = Server.CreateObject ("ADODB.") Connection ")
Response.Write IsObject (Con)
%>
Result:true

LBound ()
FUNCTION: Returns the smallest available subscript for the specified array dimension.
Syntax:lbound (Arrayname [, dimension>)
Arguments:dimension the integer that indicates which dimension lower bound to return. Using 1 means the first dimension, 2 represents the second dimension, and so on. If the dimension argument is omitted, the default value is 1.
EXAMPLE: <%
i = Array ("Monday", "Tuesday", "Wednesday")
Response.Write LBound (i)
%>
result:0

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.