Asp function Introduction (i)

Source: Internet
Author: User
Tags date format array expression functions variables variable time interval
Function

Many functions in ASP, we should focus on learning functions: function name, function function, function return value and example.

1. Function Array ()
Function: Create a number of variables
Format: Array (list)
Parameters: The list is the number of columns in the variable, and the middle is separated by the funny numbers.
Example:
<% i = Array ("1", "2", 3)%>
Results: I was given to the numbers
2. Function CInt ()
Function: Convert one expression/other type of change into integer type (int)
Format: Cint (expression)
Parameters: expression is any valid expression/other type of variable
Example:
<%
F = "234"
Response.Write CINT (f) + 2
%>
Results: 236
The function CInt () transforms the character "234" into an integer of 234. If the expression is empty or ineffective, the return value is 0;
3. Function: Creatobject ()
Function: Create and return an ActiveX image.
Format: Creatobject (obname)
Parameters: Obname is the name of the image
Example:
<%
Set con = Server.CreateObject ("ADODB.") Connection ")
%>
Outcome:
4. Function CStr ()
Function: Convert one expression/other type of change to character type (string)
Format: Cstr (expression)
Parameters: expression is any valid expression/other type of variable
Example:
<%
s = 3 + 2
Response.Write "The result is:" & CStr (s)
%>
Results: the function CStr () transforms the integer 5 into the character "5".
5. Function date ()
Function: Returns the date of the previous system (server side)
Format: Date ()
Parameters: No
Example <% date ()%>
Outcome: 05/10/00
6. Function DateAdd ()
Function: Calculate a specified time and
Format: DateAdd (timeinterval,number,date)
Parameters: TimeInterval is a time unit (month, day ...); Number is the time interval, and date is the time to start.
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
%>
Outcome:
11/4/99
3:34:45 PM
which
"M" = "month";
"D" = "Day";
If it's a currentdate format,
"H" = "Hour";
"S" = "second";
7. Function DateDiff ()
function: Calculate the time difference specified by a certain amount
Format: DateDiff (Timeinterval,date1,date2[,firstdayofweek[,firstdayofyear]])
Parameters: TimeInterval is a time unit; Date1,date2 is a valid date expression, and firstdayofweek,firstdayofyear is an arbitrary 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 certain date of the month
Format: Day (date)
Parameters: Date is a valid time-table expression;
Example lt;% =date (#8/4/99#)%>
Results: 4
9. Function FormatCurrency ()
Function: Convert into currency format
Format: formatcurrency (expression [, digit[,leadingdigit[,paren[,groupdigit]]]
Parameters: expression is a valid number expression; digit represents the digits after the decimal point; Leadingdigit,paren,groupdigit is any option.
Example <%=formatcurrency (34.3456)%>
Results 34.35
10. Function FormatDateTime ()
Features: Formatting dates Express/change
Format: FormatDateTime (Date[,nameformat])
Parameters: Date is a valid data expression/variable; NameFormat is the specified date format constant name.
Example <% =formatdatetime ("08/04/99", vbLongDate)%>
Outcome: Wednesday,august 04,1999
21. Function IsNumeric ()
Function: Returns a Boolean value, whether the variable is a number change, or can be converted to a number of other changes.
Format: isnumeric (expression)
Parameters: expression is any variable.
Example:
<%
i= "234"
Response.Write IsNumeric (i)
%>
Results: TRUE.
22. Function IsObject ()
Function: Returns a Boolean value, whether the variable is the change of the image,
Format: isobject (expression)
Parameters: expression is any variable.
Example:
<%
Set con =server.creatobject ("adodb.connection")
Response.Write IsObject (Con)
%>
Outcome: True
23. Function: Lbound ()
Function: Returns the lower bound of a group.
Format: Lbound (Arrayname[,dimension])
Parameters: Arrayname is a number of variables, dimension is any
Example:
<%
i = Array ("1", "2", "3")
Response.Write LBound (i)
%>
Results: 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.