Functions | functions
Array ()
function returns an array of
Expression Array (list)
Allow data types: characters, numbers can
Instance:
<%
Dim MyArray ()
For i = 1 to 7
Redim Preserve myarray (i)
MyArray (i) = WeekdayName (i)
Next
%>
Return result: An array containing 7 elements was established myarray
MyArray ("Sunday", "Monday", ...) "Saturday")
CInt ()
function converts an expression to a numeric type
Expression CInt (expression)
Allow data type: Any valid character can be
Instance:
<%
F = "234"
Response.Write CINT (f) + 2
%>
return Result: 236
The conversion character "234" is the number "234" and returns a value of 0 if the string is empty
CreateObject ()
function to establish and return an instance of a registered ActiveX component.
Expression CreateObject (objname)
Allow data type: objname is the name of any valid, registered ActiveX component.
Instance:
<%
Set con = Server.CreateObject ("ADODB.") Connection ")
%>
CStr ()
function to convert an expression to a string.
Expression of CStr (expression)
Allow data type: expression is any valid expression.
Instance:
<%
s = 3 + 2
Response.Write "The return result is:" & CStr (s)
%>
Return Result: Converts the number "5" to the character "5".
Date ()
function to return the current system date.
An expression Date ()
Allow data type: None.
Instance:
<%=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.
Instance:
<%
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 ()
function returns the difference between two dates.
Expression DateDiff (Timeinterval,date1,date2 [, FirstDayOfWeek [, FirstWeekOfYear]])
Allow data type: TimeInterval represents a type of time separated, such as "M" for "month".
Instance:
<%
FromDate = #9/9/00#
ToDate = #1/1/2000#
Response.Write "There are" & _
DateDiff ("D", Fromdate,todate) & _
"Millenium from 9/9/00."
%>
Return result: There are 150 days from 9/9/00 to 2000.
Day ()
function returns the day ordinal of a one-month period.
Expression Day (date)
Allow data type: Date is any valid day.
Instance:
<%=day (#9/9/00#)%>
Return Result: 4
FormatCurrency ()
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.
Instance:
<%=formatcurrency (34.3456)%>
return Result: $34.35
FormatDateTime ()
function returns an expression that has been formatted as a date or time
Expression FormatDateTime (Date, [, NamedFormat])
Allow data type: NamedFormat indicates the value of the date/time format used, and if omitted, use Vbgeneraldate.
Instance:
<%=formatdatetime ("09/9/00", vbLongDate)%>
Return results: Sunday, September 09, 2000
FormatNumber ()
function returns an expression that has been formatted as a numeric value.
Expression FormatNumber (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 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 ...
Instance:
<%=formatnumber (45.324567, 3)%>
[1] [2] Next page