ASP中的函数应用方法及应用举例(二)

21. IsObject()
FUNCTION: Returns a boolean value indicating whether an expression refers to an automation object.
SYNTAX: IsObject(expression)
ARGUMENTS: expression is any valid expression.
EXAMPLE: ```

Set con = Server.CreateObject("ADODB.Connection")
response.write IsObject(con)

 1RESULT: True   
 2\-------------------------------------   
 3  
 422\. LBound()   
 5FUNCTION: Returns the base index value for a dimension of any array.   
 6SYNTAX: Lbound(arrayname [, dimension])   
 7ARGUMENTS: arrayname is the name of any array; dimension is an optional number indicating the dimension   
 8to find the lower bound.   
 9EXAMPLE: ```
10   
11i = Array("Monday","Tuesday","Wednesday")   
12response.write LBound(i)   

RESULT: 0
-------------------------------------

23. LCase()
FUNCTION: Returns a string that has been converted into lowercase characters.
SYNTAX: Lcase(string)
ARGUMENTS: string is any valid string expression.
EXAMPLE: ```

strTest = "This is a test!"
response.write LCase(strTest)

 1RESULT: this is a test!   
 2\-------------------------------------   
 3  
 424\. Left()   
 5FUNCTION: Returns the number of characters from the left side of a string.   
 6SYNTAX: Left(string, length)   
 7ARGUMENTS: string is any valid string expression; length is the length of characters to return.   
 8EXAMPLE: ```
 9   
10strTest = "This is a test!"   
11response.write Left(strTest, 3)   

RESULT: Thi
-------------------------------------

25. Len()
FUNCTION: Returns the number of characters in a string or the number of bytes required to store a
variable.
SYNTAX: Len(string | varName)
ARGUMENTS: string is any valid string expression; varName is any valid variable name.
EXAMPLE: ```

strTest = "This is a test!"
response.write Len(strTest)

 1RESULT: 15   
 2(The total length of strTest is 15 characters)   
 326\.   
 4LTrim()   
 5FUNCTION: Returns a string without leading spaces.   
 6SYNTAX: LTrim(string)   
 7ARGUMENTS: string is any valid string expression.   
 8EXAMPLE: ```
 9   
10strTest = " This is a test!"   
11response.write LTrim(strTest)   

RESULT: This is a test!
-------------------------------------

27. Mid()
FUNCTION: Returns a specified number of characters from a string.
SYNTAX: Mid(string, start [, length])
ARGUMENTS: string is any valid string expression; start is a numeric character position to begin
extraction from; length (optional) is the number of characters to return.
EXAMPLE: ```

strTest = "This is a test! Today is Monday."
response.write Mid(strTest, 17, 5)

1RESULT: Today   
2\-------------------------------------   
3  
428\. Minute()   
5FUNCTION: Returns the number of the minutes in current system time.   
6SYNTAX: Minute(time)   
7ARGUMENTS: time is any valid time expression.   
8EXAMPLE: ```
9=Minute(#12:45:32 PM#)

RESULT: 45
-------------------------------------

29. Month()
FUNCTION: Returns the number of the month of the year.
SYNTAX: Month(date)
ARGUMENTS: date is any valid date expression.
EXAMPLE: ``` =Month(#08/04/99#)

 1RESULT: 8   
 2\-------------------------------------   
 3  
 430\. MonthName()   
 5FUNCTION: Returns a string identifying the specified month.   
 6SYNTAX: MonthName(month, [, Abb])   
 7ARGUMENTS: month is the numeric representation for a given month; Abb (optional) is a boolean value used   
 8to display month abbreviation. True will display the abbreviated month name and False (default) will not   
 9show the abbreviation.   
10EXAMPLE: ```
11=MonthName(Month(#08/04/99#))

RESULT: August
-------------------------------------

31. Now()
FUNCTION: Returns the current system date and time.
SYNTAX: Now()
ARGUMENTS: None
EXAMPLE: ``` =Now

 1RESULT: 8/4/99 9:30:16 AM   
 2\-------------------------------------   
 3  
 432\. Replace()   
 5FUNCTION: Returns a string in which a specified sub-string has been replaced with another substring a   
 6specified number of times.   
 7SYNTAX: Replace(strToBeSearched, strSearchFor, strReplaceWith [, start [, count [, compare]]])   
 8ARGUMENTS: strToBeSearched is a string expression containing a sub-string to be replaced; strSearchFor   
 9is the string expression to search for within strToBeSearched; strReplaceWith is the string expression to   
10replace sub-string strSearchFor; start (optional) is the numeric character position to begin search; count   
11(optional) is a value indicating the comparision constant.   
12EXAMPLE: ```
13   
14strTest = "This is an apple!"   
15response.write Replace(strTest, "apple", "orange")   

RESULT: This is an orange!
-------------------------------------

33. Right()
FUNCTION: Returns a specified number of characters from the right side of a string.
SYNTAX: Right(string, length)
ARGUMENTS: string is any valid string expression; length is any valid numeric expression representing
the number of characters to return.
EXAMPLE: ```

strTest = "This is an test!"
response.write Right(strTest, 3)

 1RESULT: st!   
 2\-------------------------------------   
 3  
 434\. Rnd()   
 5FUNCTION: Returns a random number.   
 6SYNTAX: Rnd [ (number) ]   
 7ARGUMENTS: number is any valid numeric expression.   
 8EXAMPLE: ```
 9   
10Randomize()   
11response.write RND()   

RESULT: Any number between 0 and 1
(Without Randomize(), the number will not re-generate)

Round()
FUNCTION: Returns a number rounded to a specified number of decimal places.
SYNTAX: Round(expression [, numRight])
ARGUMENTS: expression is any valid numeric expression to be rounded; numRight (optional) is any numeric
expression used to indicate the number of digits to the right of the decimal point.
EXAMPLE: ```

i = 32.45678
response.write Round(i)

 1RESULT: 32   
 2\-------------------------------------   
 3  
 435\. Rtrim()   
 5FUNCTION: Returns a copy of a string without trailing spaces.   
 6SYNTAX: Rtrim(string)   
 7ARGUMENTS: string is any valid string expression.   
 8EXAMPLE: ```
 9   
10strTest = "This is a test!! "   
11response.write RTrim(strTest)   

RESULT: This is a test!!
-------------------------------------

36. Second()
FUNCTION: Returns the current seconds value of the current system time.
SYNTAX: Second(time)
ARGUMENTS: time is any valid time expression.
EXAMPLE: ``` =Second(#12:34:28 PM#)

 1RESULT: 28   
 2\-------------------------------------   
 3  
 437\. StrReverse()   
 5FUNCTION: Returns a string where the character order has been reversed   
 6SYNTAX: StrReverse(string)   
 7ARGUMENTS: string is any valid string expression   
 8EXAMPLE: ```
 9   
10strTest = "This is a test!!"   
11response.write StrReverse(strTest)   

RESULT: !!tset a si sihT
-------------------------------------

38. Time()
FUNCTION: Returns the current system time.
SYNTAX: Time()
ARGUMENTS: None.
EXAMPLE: ``` =Time

 1RESULT: 9:58:28 AM   
 2\-------------------------------------   
 3  
 439\. Trim()   
 5FUNCTION: Returns a string without leading and trailing spaces.   
 6SYNTAX: Trim(string)   
 7ARGUMENTS: string is any valid string expression.   
 8EXAMPLE: ```
 9   
10strTest = " This is a test!! "   
11response.write Trim(strTest)   

RESULT: This is a test!!
-------------------------------------

40. UBound()
FUNCTION: Returns the largest available subscipt for a dimension of an array.
SYNTAX: Ubound(arrayname [, dimension])
ARGUMENTS: arrayname is the name of a valid array; dimension (optional) is a number indicating the
dimension to find the upper bound.
EXAMPLE: ```

i = Array("Monday","Tuesday","Wednesday")
response.write UBound(i)

 1RESULT: 2   
 2(array index starts with 0)   
 3\-------------------------------------   
 4  
 541\. UCase()   
 6FUNCTION: Returns a string that has been converted to uppercase characters.   
 7SYNTAX: UCase(string)   
 8ARGUMENTS: string is any valid string expression.   
 9EXAMPLE: ```
10   
11strTest = "This is a test!!"   
12response.write UCase(strTest)   

RESULT: THIS IS A TEST!!
-------------------------------------

42. VarType()
FUNCTION: Returns the subtype of a variable
SYNTAX: VarType(varName)
ARGUMENTS: varName is the required variable name
EXAMPLE: ```

i = 3
response.write varType(i)

 1RESULT: 2   
 2(2 indicates Integer. Refers to ASP Constants)   
 3\-------------------------------------   
 4  
 543\. WeekDay()   
 6FUNCTION: Returns a whole number representing the day of the week.   
 7SYNTAX: WeekDay(date [, firstdayofweek])   
 8ARGUMENTS: date is any valid date expression; firstdayofweek is an optional date constant to assign the   
 9first day of week.   
10EXAMPLE: ```
11   
12d = #8/4/99#   
13response.write Weekday(d)   

RESULT: 4
(4 indicates the fourth of the week, which is Wednesday)
-------------------------------------

44. WeekDayName()
FUNCTION: Returns the specified day of the week.
SYNTAX: WeekDayName(weekday [, Abb [, firstdayofweek]])
ARGUMENTS: weekday is the numeric representation for the day of the week; Abb is an optional boolean
value (if set to true, the weekday name will be abbreviated; if set to false, the full weekday name is
displayed); and firstdayofweek is an optional date constant to assign the first day of week.
EXAMPLE: ```

d = #8/4/99#
response.write WeekdayName(Weekday(d))

1RESULT: Wednesday   
2\-------------------------------------   
3  
445\. Year()   
5FUNCTION: Returns the current year.   
6SYNTAX: Year(date)   
7ARGUMENTS: date is any valid date expression.   
8EXAMPLE: ```
9=Year(#8/4/99#)
Published At
Categories with Web编程
Tagged with
comments powered by Disqus