ASP Series function Encyclopedia (1)

Source: Internet
Author: User
function ASP function Encyclopedia


ASP functions are similar to VBScript, here are some common functions


 


Array ()


 

The
function returns an array


 


expression Array (list)


 


allow data types: characters, numbers can be


 


Example: <%


 


Dim myarray ()


 


for i = 1 to 7


 


Redim Preserve myarray (i)


 


myarray (i) = WeekdayName (i)


 


Next


 


%>


 


Returns the result: an array containing 7 elements was established myarray





myarray ("Sunday", "Monday", ...) "Saturday")


 


 


CInt ()


 

The
function converts an expression to a numeric type


 


expression CInt (expression)


 


allow data types: Any valid characters can be


 


Example: <%


 


f = "234"


 


Response.Write CINT (f) + 2


 


%>


 


return Result: 236


 


converts the character "234" to the number "234" and returns a value of 0 if the string is empty


 


 


CreateObject ()




The
function establishes and returns 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 ()


 

The
function converts an expression to a string.


 


expression-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 ()


 

The
function returns the current system date.


 


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 ()


 

The
function returns the difference between two dates.


 


expression DateDiff (timeinterval,date1,date2 [, FirstDayOfWeek [, FirstWeekOfYear]])


 


allows data types: TimeInterval represents a type of time between intervals, 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 results: From 9/9/00 to 2000 there are 150 days.


 


 


Day ()


 

The
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 ()


 

The
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.





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.