ASP common functions and detailed descriptions page 1/2

Source: Internet
Author: User

All the functions and detailed descriptions used in ASP are posted for your learning.
I know the following:
1. Function array ()
Function: creates an array variable.
Format: array (list)
Parameter: list is each numeric column in the array variable, separated by commas (,).
Example:
<% I = array ("1", "2", "3") %>
Result: I is assigned as an array.
2. Function Cint ()
Function: converts an expression or another type of variable to an integer (int)
Format: Cint (expression)
Parameter: expression is a valid expression or variable of other types.
Example:
<%
F = "234"
Response. write cINT (f) + 2
%>
Result: 236
The Cint () function converts the character "234" to an integer 234. If the expression is null or is invalid, the return value is 0;
3. function: Creatobject ()
Function: Creates and returns an ActiveX object.
Format: Creatobject (obname)
The bname parameter is the object name.
Example:
<%
Set con = Server. CreateObject ("ADODB. Connection ")
%>
Result:
4. Function Cstr ()
Function: converts an expression or another type of variable to a string)
Format: Cstr (expression)
Parameter: expression is a valid expression or variable of other types.
Example:
<%
S = 3 + 2
Response. write "The result is:" & cStr (s)
%>
Result: The Cstr () function converts integer 5 to the "5" character ".
5. function Date ()
Function: returns the date of the current system (server ).
Format: Date ()
Parameter: None
Example <% date () %>
Results: 05/10/00
6. Function Dateadd ()
Function: Calculate a specified time and
Format: dateadd (timeinterval, number, date)
Parameter: timeinterval is the time unit (month, day...); number is the time interval value, and date is the time start point.
Example:
<%
CurrentDate = #8/4/99 #
NewDate = DateAdd ("m", 3, currentDate)
Response. write newDate
%> <%
CurrentDate = #12:34:45 #
NewDate = DateAdd ("h", 3, currentDate)
Response. write newDate
%>
Result:
11/4/99
3:34:45
Where
"M" = "month ";
"D" = "day ";
If the format is currentDate, then,
"H" = "hour ";
"S" = "second ";
7. Function Datediff ()
Function: calculates the time difference between a specified number of values.
Format: datediff (timeinterval, date1, date2 [, firstdayofweek [, firstdayofyear])
Parameter: timeinterval is the 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 )&_
"Days to millenium from 8/4/99 ."
%>
Result: There are 150 days to millenium from 8/4/99.
8. function day ()
Function: returns an integer corresponding to a day of a month.
Format: day (date)
Parameter: date is a valid date expression;
Example <% = date (#8/4/99 #) %>
Result: 4
9. Function formatcurrency ()
Function: convert to a currency format.
Format: formatcurrency (expression [, digit [, leadingdigit [, paren [, groupdigit])
Parameter: expression is a valid numeric expression; digit indicates the number of digits after the decimal point; leadingdigit, paren, groupdigit is any option.
Example <% = formatCurrency (34.3456) %>
Result 34.35
10. Function formatdatetime ()
Function: format a date expression or variable.
Format: formatdatetime (date [, nameformat])
Parameter: date is a valid date expression/variable. nameformat is the constant name of the specified date format.
Example <% = formatdatetime ("08/04/99", vblongdate) %>
Result: Wednesday, August 04,1999
Note:
------------------------------------------------------------------- <Script language = vbs>
For I = 0 to 4
When alert ("formatdatetime (now," & I & ") is:" & formatdatetime (now, I ))
Next
</Script>

-------------
Description
Return expression, which has been formatted as a date or time.
Syntax
FormatDateTime (Date [, Namedformat])
The syntax of the formatDateTime function includes the following parameters:

Parameter description
Date is required. The date expression to be formatted.
Namedformat is optional. Indicates the value of the date/time format used. If it is omitted, vbGeneralDate is used.

Set
The Namedformat parameter can have the following values:
Constant Value description
VbGeneralDate 0 displays the date and/or time. If there is a date part, it is displayed as the short date format. If there is a time part, it is displayed as a long time format. If all exist, all parts are displayed.
VbLongDate 1 displays the date in the long date format specified in the computer region settings.
Vb1_date 2 displays the date in the short date format specified in the computer region settings.
VbLongTime 3 displays the time in the specified time format in the computer region settings.
Vb1_time 4 uses the 24-hour format (hh: mm) to display the time.

Description
The following example uses the formatDateTime function to format the expression as a long date type and assign it to MyDateTime:
Function GetCurrentDate
"FormatDateTime format the date type to the long date type.
GetCurrentDate = formatDateTime (Date, 1)
End Function
--------------------------------------------------------------------------------
<Script language = vbs>
For I = 0 to 4
When alert ("formatdatetime (now," & I & ") is:" & formatdatetime (now, I ))
Next
</Script>
[Ctrl + A select all tips: you can modify some code and then press run]

11. Function Isnumeric ()
Function: returns a Boolean value to determine whether the variable is a numeric variable or another variable that can be converted to a number.
Format: isnumeric (expression)
Parameter: expression is an arbitrary variable.
Example:
<%
I = "234"
Response. write isnumeric (I)
%>
Result: true.
12. Function Isobject ()
Function: returns a Boolean value to determine whether the variable is an object variable,
Format: isobject (expression)
Parameter: expression is an arbitrary variable.
Example:
<%
Set con = server. creatobject ("adodb. connection ")
Response. write isobject (con)
%>
Result: true.
13. function: Lbound ()
Function: returns the lower bound to an array.
Format: Lbound (arrayname [, dimension])
Parameter: arrayname is an array variable, and dimension is any item.
Example:
<%
I = array ("1", "2", "3 ")
Response. write lbound (I)
%>
Result: 0
14. Function Lcase ()
Function: converts all characters of a One-character type variable to lowercase characters.
Format: Lcase (string)
Parameter: string is a string variable.
Example:
<%
Str = "THIS is Lcase! "
Response. write Lcase (str)
%>
Result: this is lcase!
15. function left ()
Function: truncates the first part of a string;
Format: left (string, length)
Parameter: string, the length of the part intercepted by length.
Example: <% = left ("this is a test! ", 6) %>
Result: this I
16. Function len ()
Function: returns the length of a string or the length of a variable in bytes.
Format: len (string * varname)
Parameter: string; any variable name of varname
Example:
<%
Strtest = "this is a test! "
Response. write len (strtest)
%>
Result: 15
17. Function ltrim ()
Function: removes spaces before a string.
Format: ltrim (string)
Parameter: string.
Example: <% = ltrim ("this is a test! ")
Result: this is a test!
18. function Mid ()
Function: truncates a string from a string.
Format: mid (string, start [, length])
Parameter: string, the start point of start truncation, And the length to be truncated.
Example:
<%
Strtest = "this is a test, Today is Monday! "
Response. write mid (strtest, 17,5)
%>
Result: Today
19. Function minute ()
Function: returns a value, indicating minutes.
Format: minute (time)
Parameter: time is the time variable.
Example lt; % = minute (#12:23:34 #) %>
Result: 23

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.