Recommended: Session skills in ASP Anyone who has written a slightly larger ASP knows that Session is really useful. It can be used to record user-owned data variables, which is both safe and convenient. But do you really know how session works? Maybe after you understand, you will never dare to use this again
Function: Return an array
Syntax: Array(list)
Applicable types: characters, numbers are available
| The following is the quoted content: <% Dim myArray() For i = 1 to 7 Redim Preserve myArray(i) myArray(i) = WeekdayName(i) Next %> |
Result: An array containing 7 elements is created myArray
myArray(Sunday,Monday, ... ... Saturday)
CInt()
Function: Convert an expression to a numeric type
Syntax: CInt (expression)
Applicable type: Any valid character is OK
| The following is the quoted content: <% f = 234 response.write cINT(f) 2 %> |
Results: 236
Convert character 234 to number 234, if the string is empty, return 0 value
CreateObject()
Function: Create and return an instance of the registered ACTIVEX component.
Syntax: CreateObject(objName)
Applicable Type: objName is the name of any valid, registered ACTIVEX component.
| The following is the quoted content: <% Set con = Server.CreateObject(ADODB.Connection) %> CStr() |
Function: Convert an expression to a string.
Syntax: CStr(expression)
Applicable type: expression is any valid expression
| The following is the quoted content: <% s = 3 2 response.write(The result is: & cStr(s)) %> |
Result: Convert the number 5 to character 5.
Date()
Function: Return the current system date.
Syntax: Date()
Applicable type: None.
<%=Date%>
Results: 8/4/99
DateAdd()
Function: Returns a changed date.
Syntax: DateAdd(timeinterval,number,date)
Description: timeinterval is the time interval type to be added; number is the number to be added; date is the starting date.
| The following is the quoted content: <% 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 m = month; d = day; When the current date format is time, then h = hour; s = second; DateDiff() |
Function: Return the difference between two dates.
Syntax: DateDiff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear >>)
Description: timeinterval represents the type of time interval, such as M represents the month.
| The following is the quoted content: <% fromDate = #8/4/99# toDate = #1/1/2000# response.write(There are & _ DateDiff(d,fromDate,toDate) & _ days to millionium from 8/4/99. %> |
Results: There are 150daysto millionium from 8/4/99
Day()
Function: Return to the day of a month.
Syntax: Day(date)
Description: date is any valid date.
<%=Day(#8/4/99#)%>
Results: 4
FormatCurrency()
Function: Returns the expression, which has been formatted as a currency value
Syntax: FormatCurrency(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit >>>>)
Description: Digit indicates the value of the number of digits displayed on the right side of the decimal point. The default value is -1, indicating that the computer's locale is used; LeadingDigit three-state constant, indicating whether the zero before the decimal value is displayed.
<%=FormatCurrency(34.3456)%>
Results: $34.35
FormatDateTime()
Function: Returns the expression, which has been formatted as a date or time
Syntax: FormatDateTime(Date, [, NamedFormat >)
Description: NamedFormat indicates the value of the date/time format used, and if omitted, vbGeneralDate is used.
<%=FormatDateTime(08/4/99, vbLongDate)%>
Results: Wednesday, August 04, 1999
FormatNumber()
Function: Returns the expression, which has been formatted as a numeric value
Syntax: FormatNumber(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit >>>>)
Description: Digit indicates the value of the number of digits displayed on the right side of the decimal point. The default value is -1, indicating that the computer's locale is used. ; LeadingDigit i indicates the number of digits displayed on the right side of the decimal point
Value. The default value is -1, indicating that the computer's locale is used. ; Parent indicates the value of the number of digits displayed on the right side of the decimal point. The default value is -1, indicating that the computer is being used.
set up. ; GroupDigit i indicates the value of the number of digits displayed on the right side of the decimal point. The default value is -1, indicating that the computer's locale is used.
<%=FormatNumber(45.324567, 3)%>
Results: 45.325
FormatPercent()
Function: Returns the expression, which has been formatted as a percentage trailing with the % sign (multiplied by 100). (%)
Syntax: FormatPercent(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit >>>>)
Note: Same as above
<%=FormatPercent(0.45267, 3)%>
Results: 45.267%
Hour()
Function: Return the number of hours at 24 o'clock
Syntax: Hour(time)
illustrate:
<%=Hour(#4:45:34 PM#)%>
Results: 16
Instr()
Function: Returns the position where a character or string first appears in another string.
Syntax: Instr([start, > strToBeSearched, strSearchFor [, compare>)
Description: Start is the starting value of the search, strToBeSearched accepts the search string strSearchFor the character to be searched Comparison method (see ASP constant for details)
| The following is the quoted content: <% strText = This is a test!! pos = Instr(strText, a) response.write pos %> |
Results: 9
InstrRev()
Function: Same as above, just starting from the last search of the string
Syntax: InstrRev([start, > strToBeSearched, strSearchFor [, compare>)
Note: Same as above.
| The following is the quoted content: <% strText = This is a test!! pos = InstrRev(strText, s) response.write pos %> |
Results: 13
Int()
Function: Return the numerical type, not rounded.
Syntax: Int(number)
illustrate:
<%=INT(32.89)%>
Results: 32
IsArray()
Function: determine whether an object is an array and return a Boolean value.
Syntax: IsArray(name)
illustrate:
| The following is the quoted content: <% strTest = Test! response.write IsArray(strTest) %> |
Results: False
IsDate()
Function: determine whether an object is a date and return the boolean syntax: IsDate(expression) Description: expression is any valid expression.
| The following is the quoted content: <% strTest = 8/4/99 response.write IsDate(strTest) %> |
Results: True
IsEmpty()
Function: determine whether an object is initialized and returns a Boolean value.
Syntax: IsEmpty(expression)
illustrate:
| The following is the quoted content: <% Dim i response.write IsEmpty(i) %> |
Results: True
IsNull()
Function: determine whether an object is empty and return a Boolean value.
Syntax: IsNull(expression)
illustrate:
| The following is the quoted content: <% Dim i response.write IsNull(i) %> |
Results: False
IsNumeric()
Function: determine whether an object is a number and return a Boolean value.
Syntax: IsNumeric(expression)
illustrate:
| The following is the quoted content: <% i = 345 response.write IsNumeric(i) %> |
Results: True
Even if the number is quoted, ASP still thinks it is a number.
IsObject()
Function: determine whether an object is an object and return a Boolean value.
Syntax: IsObject(expression)
illustrate:
| The following is the quoted content: <% Set con = Server.CreateObject( ADODB.Connection) response.write IsObject(con) %> |
Results: True
LBound()
Function: Returns the minimum available subscript for the specified array dimension.
Syntax: Lbound(arrayname [, dimension >)
Description: dimension indicates which dimension the integer to return to. Use 1 to represent the first dimension, 2 to represent the second dimension, and so on. If the dimension parameter is omitted, the default value is 1.
| The following is the quoted content: <% i = Array( Monday,Tuesday,Wednesday) response.write LBound(i) %> |
Results: 0
LCase()
Function: Return the lowercase form of the string
Syntax: Lcase(string)
Description: string is any valid string expression.
| The following is the quoted content: <% strTest = This is a test! response.write LCase(strTest) %> |
Results: this is a test!
Left()
Function: Return the character before the length character on the left side of the string (including the length character).
Syntax: Left(string, length)
illustrate:
| The following is the quoted content: <% strTest = This is a test! response.write Left(strTest, 3) %> |
Results: Thi
Len()
Function: Return the length of the string.
Syntax: Len(string | varName)
illustrate:
| The following is the quoted content: <% strTest = This is a test! response.write Len(strTest) %> |
Results: 15
LTrim()
Function: Remove the spaces on the left side of the string.
Syntax: LTrim(string)
illustrate:
| The following is the quoted content: <% strTest = This is a test! response.write LTrim(strTest) %> |
Results: This is a test!
Mid()
Function: Return a string of a specific length (start, length is length).
Syntax: Mid(string, start [, length >)
illustrate:
| The following is the quoted content: <% strTest = This is a test! Today is Monday. response.write Mid(strTest, 17, 5) %> |
Results: Today
Minute()
Function: Return to the time.
Syntax: Minute(time)
illustrate:
<%=Minute(#12:45:32 PM#)%>
Results: 45
Month()
Function: Return date.
Syntax: Month(date)
Description: date is any valid date expression.
<%=Month(#08/04/99#)%>
Results: 8
MonthName()
Function: Returns a string identifying the specified month.
Syntax: MonthName(month, [, Abb >)
Description: month is the numeric representation for a given month; Abb (optional) is a boolean value used to display month abbreviation. True will display the abbreviated month name and False (default) will not show the abbreviation.
<%=MonthName(Month(#08/04/99#))%>
Results: August
Now()
Function: Returns the current system date and time. Returns the current system time
Syntax: Now()
Description: None
<%=Now%>
Results: 8/4/99 9:30:16 AM
Replace()
Function: Returns a string in which a specified sub-string has been replaced with another substring a specified number of times.
Syntax: Replace(strToBeSearched, strSearchFor, strReplaceWith [, start [, count [, compare >>>)
| The following is the quoted content: Description: strToBeSearched is a string expression containing a sub-string to be replaced; strSearchFor is the string expression to search for within strToBeSearched; strReplaceWith is the string expression to replace sub-string strSearchFor; start (optional) is the numeric character position to begin search; count (optional) is a value indicating the comparison constant. <% strTest = This is an apple! response.write Replace(strTest, apple, orange) %> |
Results: This is an orange!
Right()
Function: Return the character before the length character on the right side of the string (including the length character).
Syntax: Right(string, length)
illustrate:
| The following is the quoted content: <% strTest = This is an test! response.write Right(strTest, 3) %> |
Results: st!
Rnd()
Function: generate a random number.
Syntax: Rnd [ (number) >
illustrate:
| The following is the quoted content: <% Randomize() response.write RND() %> |
Result: Any number between 0 and 1
Round()
Function: Returns the value rounded by the specified number of digits.
Syntax: Round(expression [, numRight >)
Description: The numRight number indicates how many digits are rounded to the right of the decimal point. If omitted, the Round function returns an integer.
| The following is the quoted content: <% i = 32.45678 response.write Round(i) %> |
Results: 32
Rtrim()
Function: Remove the space string on the right side of the string.
Syntax: Rtrim(string)
illustrate:
| The following is the quoted content: <% strTest = This is a test!! response.write RTrim(strTest) %> |
Results: This is a test!!
Second()
Function: Return seconds.
Syntax: Second(time)
illustrate:
<%=Second(#12:34:28 PM#)%>
Results: 28
StrReverse()
Function: reversely arrange a string
Syntax: StrReverse(string)
illustrate
| The following is the quoted content: <% strTest = This is a test!! response.write StrReverse(strTest) %> |
Results:!!tset a si sihT
Time()
Function: Return system time.
Syntax: Time()
illustrate:
<%=Time%>
Results: 9:58:28 AM
Trim()
Function: Remove the spaces on the left and right of the string.
Syntax: Trim(string)
Description: string is any valid string expression.
| The following is the quoted content: <% strTest = This is a test!! response.write Trim(strTest) %> |
Results: This is a test!!
UBound()
Function: Returns the maximum available subscript for the specified array dimension.
Syntax: Ubound(arrayname [, dimension >)
Description: dimension (optional) specifies the integer in which dimension is returned. 1 means the first dimension, 2 means the second dimension, and so on. If the dimension parameter is omitted, the default value is 1.
| The following is the quoted content: <% i = Array( Monday,Tuesday,Wednesday) response.write UBound(i) %> |
Results: 2
UCase()
Function: Return the uppercase form of the string.
Syntax: UCase(string)
illustrate:
| The following is the quoted content: <% strTest = This is a test!! response.write UCase(strTest) %> |
Results: THIS IS A TEST!!
VarType()
Function: Returns the value indicating the subtype of the variable
Syntax: VarType(varName)
illustrate:
| The following is the quoted content: <% i = 3 response.write varType(i) %> |
Result: See the asp constant for details for 2 (number).
WeekDay()
Function: Return to the day of the week.
Syntax: WeekDay(date [, firstdayofweek >)
illustrate:
| The following is the quoted content: <% d = #8/4/99# response.write Weekday(d) %> |
Results: 4 (Wednesday)
WeekDayName()
Function: Return the name of the day of the week.
Syntax: WeekDayName(weekday [, Abb [, firstdayofweek >>)
Description: Abb is optional. Boolean value, indicating whether the abbreviation represents the name of each day of the week. If omitted, the default value is False, which means that the names of each day of the week are not abbreviated. Firstdayofweek refers to the value of the first day of the week.
| The following is the quoted content: <% d = #8/4/99# response.write WeekdayName(Weekday(d)) %> |
Results: Wednesday
Year()
Function: Return to the current year.
Syntax: Year(date)
illustrate:
<%=Year(#8/4/99#)%>
Results: 1999
Share: ASP implements the non-existent web page to automatically send emails When we make a website, we usually have some errors in the visitor's actions or defects in our website itself, causing a non-existent page to be visited. At this time, a 404 error message will appear. If it is an enthusiastic visitor, it may send you an email to remind you. At that time, most of the people