ASP Function Introduction

Source: Internet
Author: User
Tags date1 integer numeric time interval valid

1. Function Array ()

function: Create an array variable


format: Array (list)


parameter: List each numeric column in an array variable, with a comma interval between


Example:


<% i = Array ("1", "2", 3)%>


Result: I was given an array of


2. Function CInt ()


function: Converts an expression/other type of variable to an integer type (int)


format: Cint (expression)


parameter: expression is any valid expression/other type of variable


Example:


<%


f = "234"


Response.Write CINT (f) + 2


%>


Result: 236

The
function CInt () converts the character "234" to an integer 234. If the expression is empty or invalid, the return value is 0;


3. Function: Creatobject ()


function: Creates and returns an ActiveX object.


format: Creatobject (obname)


parameter: Obname is the name of the object


Example:


<%


Set con = Server.CreateObject ("ADODB.") Connection ")


%>


Results:


4. Function CStr ()


Function: Converts an expression/other type of variable to a character type (string)


format: Cstr (expression)


parameter: expression is any valid expression/other type of variable


Example:


<%


s = 3 + 2


Response.Write "The result is:" & CStr (s)


%>


Result: the function CStr () converts the integer 5 to the character "5".


5. Function date ()


function: Returns the date of the current system (server side)


format: Date ()


parameter: No


example <% date ()%>


results: 05/10/00


6. Function DateAdd ()


function: Calculates a specified time and


format: DateAdd (timeinterval,number,date)


parameter: TimeInterval is the time unit (month, day ...); Number is the time interval value, date is the point of origin.


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


%>


Results:


11/4/99


3:34:45 PM


which


"M" = "month";


"D" = "Day";


if it is a currentdate format, then


"H" = "Hour";


"S" = "second";


7. Function DateDiff ()


function: Calculates a specified time difference for a certain amount


format: DateDiff (Timeinterval,date1,date2[,firstdayofweek[,firstdayofyear])


parameter: TimeInterval is a time unit; Date1,date2 is a valid date expression, Firstdayofweek,firstdayofyear is any option.


Example:


<%


fromdate = #8/4/99#


toDate = #1/1/2000#


Response.Write "There are" & _


DateDiff ("D", Fromdate,todate) & _


"Millenium from 8/4/99."


%>


results: There are to millenium from 8/4/99.


8. Function Day ()


function: Returns an integer value that corresponds to a day of the month


format: Day (date)


parameter: date is a valid datetime expression;


Example lt;% =date (#8/4/99#)%>


Result: 4


9. Function FormatCurrency ()


function: Convert to currency format


format: formatcurrency (expression [, Digit[,leadingdigit[,paren[,groupdigit]]])


parameter: expression is a valid numeric expression, digit represents the number of digits after the decimal point, and leadingdigit,paren,groupdigit is any option.


Example <%=formatcurrency (34.3456)%>


Results 34.35


10. Function FormatDateTime ()


function: Format date expression/variable


format: FormatDateTime (Date[,nameformat])


parameter: Date expression/variable is valid, NameFormat is the specified date format constant name.


Example <% =formatdatetime ("08/04/99", vblongdate)%>


results: Wednesday,august 04,1999


21. Function IsNumeric ()


function: Returns a Boolean value that determines whether a variable is a numeric variable or another variable that can be converted to a number.


format: isnumeric (expression)


parameter: expression is any variable.


Example:


<%


i= "234"


Response.Write IsNumeric (i)


%>


Result: true.


22. Function IsObject ()


function: Returns a Boolean value that determines whether a variable is an object,


format: isobject (expression)


parameter: expression is any variable.


Example:


<%


set con =server.creatobject ("adodb.connection")


Response.Write IsObject (Con)


%>


Result: True


23. Function: Lbound ()


function: Returns the lower bound of an array.


format: Lbound (Arrayname[,dimension])


parameter: arrayname is an array variable, dimension is any item


Example:


<%


i = Array ("1", "2", "3")


Response.Write LBound (i)


%>


Results: 0

24. Function LCase ()
Feature: Converts the character of a character type variable to all lowercase characters.
Format: Lcase (String)
parameter: string is a string variable
Example:
<%
str= "This is lcase!"
Response.Write Lcase (str)
%>
Results: This is lcase!
25. Function left ()
function: Intercepts the front part of a string;
Format: Left (string,length)
Parameter: string, length intercepted.
Example: <% =left ("This is a test!", 6)%>
Result: this I
26. Function len ()
Function: Returns the length of a string or the byte length of a variable
format: Len (string |varname
Parameter: string string; varname arbitrary variable name
Example:
<%
strtest= "This is a test!" &NBSP;

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.