Below is a detailed analysis of the usage of common functions of Asp that the editor has shared with you. Interested friends, let’s learn about it with the editor!
Array()
FUNCTION: Return an array
SYNTAX:Array(list)
ARGUMENTS: Characters and numbers are OK
EXAMPLE:
DimmyArray()
Fori=1to7
RedimPreservemyArray(i)
myArray(i)=WeekdayName(i)
Next
%>
RESULT: Create an array of 7 elements myArray
myArray("Sunday","Monday",......"Saturday")
CInt()
FUNCTION: Convert an expression to a numeric type
SYNTAX:CInt(expression)
ARGUMENTS: Any valid character can
EXAMPLE:
f="234"
response.writecINT(f)+2
%>
RESULT:236
Convert the character "234" to the number "234", and if the string is empty, return 0 value
CreateObject()
FUNCTION: Creates and returns an instance of the registered ACTIVEX component.
SYNTAX:CreateObject(objName)
ARGUMENTS:objName is the name of any valid, registered ACTIVEX component.
EXAMPLE:
Setcon=Server.CreateObject("ADODB.Connection")
%>
RESULT:
CStr()
FUNCTION: Convert an expression to a string.
SYNTAX:CStr(expression)
ARGUMENTS:expression is any valid expression.
EXAMPLE:
s=3+2
response.write"Theresultis:"&cStr(s)
%>
RESULT: Convert the number "5" to the character "5".
Date()
FUNCTION: Returns the current system date.
SYNTAX:Date()
ARGUMENTS:None.
EXAMPLE:
RESULT:8/4/99
DateAdd()
FUNCTION: Returns a changed date.
SYNTAX:DateAdd(timeinterval,number,date)
ARGUMENTS: timeintervallistthetimeintervaltoadd;numberisamountoftimeintervalstoadd;and
dateistactingdate.
EXAMPLE:
currentDate=#8/4/99#
newDate=DateAdd("m",3,currentDate)
response.writenewDate
%>
currentDate=#12:34:45PM#
newDate=DateAdd("h",3,currentDate)
response.writenewDate
%>
RESULT:11/4/99
3:34:45PM
"m"="month";
"d"="day";
IfcurrentDateisintimeformatthen,
"h"="hour";
"s"="second";
DateDiff()
FUNCTION: Returns the difference between two dates.
SYNTAX:DateDiff(timeinterval,date1,date2[,firstdayofweek[,firstweekofyear>>)
ARGUMENTS: timeinterval represents the type of time interval, such as "M" represents "month".
EXAMPLE:
fromDate=#8/4/99#
toDate=#1/1/2000#
response.write"Thereare"&_
DateDiff("d",fromDate,toDate)&_
"daystomilleniumfrom8/4/99."
%>
RESULT: There are 150 days left from 8/4/99 to 2000.
Day()
FUNCTION: What day does it return to?
SYNTAX:Day(date)
ARGUMENTS:date is any valid date.
EXAMPLE:
RESULT:4
FormatCurrency()
FUNCTION: Returns the expression, which has been formatted as a currency value
SYNTAX:FormatCurrency(Expression[,Digit[,LeadingDigit[,Paren[,GroupDigit>>>>)
ARGUMENTS: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 point is displayed.
EXAMPLE:
RESULT:$34.35
FormatDateTime()
FUNCTION: Returns the expression, which has been formatted as a date or time
SYNTAX:FormatDateTime(Date,[,NamedFormat>)
ARGUMENTS:NamedFormat indicates the value of the date/time format used, and if omitted, vbGeneralDate is used.
EXAMPLE:
RESULT:Wednesday, August04,1999
FormatNumber()
FUNCTION: Returns the expression, which has been formatted as a numeric value.
SYNTAX:FormatNumber(Expression[,Digit[,LeadingDigit[,Paren[,GroupDigit>>>>)
ARGUMENTS: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 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. ;Paren 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. ;GroupDigiti 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 use is
Computer's locale settings. .
EXAMPLE:
RESULT: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>>>>)
ARGUMENTS: Same as above.
EXAMPLE:
RESULT:45.267%
Hour()
FUNCTION: Returns the number of hours at 24.
SYNTAX:Hour(time)
ARGUMENTS:
EXAMPLE:
RESULT:16
(Hourhasbeenconvertedto24-hoursystem)
Instr()
FUNCTION: Returns the position where a character or string first appears in another string.
SYNTAX:Instr([start,>strToBeSearched,strSearchFor[,compare>)
ARGUMENTS:Start is the starting value of the search, strToBeSearched accepts the search string strSearchFor the character to be searched compare method
(See ASP constant for details)
EXAMPLE:
strText="Thisisastest!!"
pos=Instr(strText,"a")
response.writepos
%>
RESULT:9
InstrRev()
FUNCTION: Same as above, just starting from the last search of the string
SYNTAX:InstrRev([start,>strToBeSearched,strSearchFor[,compare>)
ARGUMENTS: Same as above.
EXAMPLE:
strText="Thisisastest!!"
pos=InstrRev(strText,"s")
response.writepos
%>
RESULT:13
Int()
FUNCTION: Returns the numerical type, not rounded.
SYNTAX:Int(number)
ARGUMENTS:
EXAMPLE:
RESULT:32
IsArray()
FUNCTION: determines whether an object is an array and returns a Boolean value.
SYNTAX:IsArray(name)
ARGUMENTS:
EXAMPLE:
strTest="Test!"
response.writeIsArray(strTest)
%>
RESULT:False
IsDate()
FUNCTION: determines whether an object is a date and returns a Boolean value
SYNTAX:IsDate(expression)
ARGUMENTS:expressionisanyvalidexpression.
EXAMPLE:
strTest="8/4/99"
response.writeIsDate(strTest)
%>
RESULT:True
IsEmpty()
FUNCTION: determines whether an object is initialized and returns a Boolean value.
SYNTAX:IsEmpty(expression)
ARGUMENTS:
EXAMPLE:
Dimi
response.writeIsEmpty(i)
%>
RESULT:True
IsNull()
FUNCTION: determines whether an object is empty and returns a Boolean value.
SYNTAX:IsNull(expression)
ARGUMENTS:
EXAMPLE:
Dimi
response.writeIsNull(i)
%>
RESULT:False
IsNumeric()
FUNCTION: determines whether an object is a number and returns a Boolean value.
SYNTAX:IsNumeric(expression)
ARGUMENTS:
EXAMPLE:
i="345"
response.writeIsNumeric(i)
%>
RESULT:True
Even if the number is quoted, ASP still thinks it is a number.
IsObject()
FUNCTION: determines whether an object is an object and returns a Boolean value.
SYNTAX:IsObject(expression)
ARGUMENTS:
EXAMPLE:
Setcon=Server.CreateObject("ADODB.Connection")
response.writeIsObject(con)
%>
RESULT:True
LBound()
FUNCTION: Returns the minimum available subscript for the specified array dimension.
SYNTAX:Lbound(arrayname[, dimension>)
ARGUMENTS:dimensional indicates which dimension the integer in the lower bound to be returned. Use 1 to represent the first dimension, 2 to represent the second dimension, and so on. If omitted
The dimension parameter has the default value of 1.
EXAMPLE:
i=Array("Monday","Tuesday","Wednesday")
response.writeLBound(i)
%>
RESULT:0
LCase()
FUNCTION: Returns the lowercase form of a string
SYNTAX:Lcase(string)
ARGUMENTS: stringisanyvalidstringexpression.
EXAMPLE:
strTest="Thisisastest!"
response.writeLCase(strTest)
%>
RESULT: thisisastest!
Left()
FUNCTION: Returns the character before the length character on the left side of the string (including the length character).
SYNTAX:Left(string,length)
ARGUMENTS:
EXAMPLE:
strTest="Thisisastest!"
response.writeLeft(strTest,3)
%>
RESULT:Thi
Len()
FUNCTION: Returns the length of the string.
SYNTAX:Len(string|varName)
ARGUMENTS:
EXAMPLE:
strTest="Thisisastest!"
response.writeLen(strTest)
%>
RESULT:15
LTrim()
FUNCTION: Remove the space on the left side of the string.
SYNTAX:LTrim(string)
ARGUMENTS:
EXAMPLE:
strTest="Thisisastest!"
response.writeLTrim(strTest)
%>
RESULT:Thisisastest!
Mid()
FUNCTION: Returns a string of a specific length (start, length is length).
SYNTAX:Mid(string,start[,length>)
ARGUMENTS:
EXAMPLE:
strTest="Thisistest!TodayisMonday."
response.writeMid(strTest,17,5)
%>
RESULT:Today
Minute()
FUNCTION: Return to the time.
SYNTAX:Minute(time)
ARGUMENTS:
EXAMPLE:
RESULT:45
Month()
FUNCTION: Return date.
SYNTAX:Month(date)
ARGUMENTS:dateisanyvaliddateexpression.
EXAMPLE:
RESULT:8
MonthName()
FUNCTION:Returnsastringidentifying the specified month.
SYNTAX:MonthName(month,[,Abb>)
ARGUMENTS:monthisthenmericrepresentationforgivenmonth;Abb(optional)isabooleanvalue
usedtodisplaymonthabbreviation.Truewill displaytheabbreviatedmonthnameandFalse(default)will
notshowtheabbreviation.
EXAMPLE:
RESULT:August
Now()
FUNCTION:Returnsthecurrentsystemdateandtime.
SYNTAX:Now()
ARGUMENTS:None
EXAMPLE:
RESULT:8/4/999:30:16AM
Replace()
FUNCTION: Returnsastringin which specified sub-stringhasbeenreplaced with no otherrsubstring
specified numberoftimes.
SYNTAX:Replace(strToBeSearched,strSearchFor,strReplaceWith[,start[,count[,compare>>>)
ARGUMENTS:strToBeSearcheddistisstringexpressioncontainingasub-stringtobereplaced;
strSearchForistthestringexpressiontosearchforwithinstrToBeSearched;strReplaceWithisthestring
expressiontoreplacesub-stringstrSearchFor; start(optional)isthenumericcharacterpositionto
beginsearch;count(optional)isavalueindicating the comparisonconstant.
EXAMPLE:
strTest="Thisisanapple!"
response.writeReplace(strTest,"apple","orange")
%>
RESULT:Thisisanorange!
Right()
FUNCTION: Returns the character before the length character on the right side of the string (including the length character).
SYNTAX:Right(string, length)
ARGUMENTS:.
EXAMPLE:
strTest="Thisisantest!"
response.writeRight(strTest,3)
%>
RESULT:st!
Rnd()
FUNCTION: Generates a random number.
SYNTAX:Rnd[(number)>
ARGUMENTS:
EXAMPLE:
Randomize()
response.writeRND()
%>
RESULT: Any number between 0 and 1
Round()
FUNCTION: Returns the value rounded by the specified number of digits.
SYNTAX:Round(expression[,numRight>)
ARGUMENTS: numRight number indicates how many digits are rounded to the right of the decimal point. If omitted, the Round function returns an integer.
EXAMPLE:
i=32.45678
response.writeRound(i)
%>
RESULT:32
Rtrim()
FUNCTION: Remove the string to the right of the string.
SYNTAX:Rtrim(string)
ARGUMENTS:
EXAMPLE:
strTest="Thisisastest!!"
response.writeRTrim(strTest)
%>
RESULT:Thisisastest!!
Second()
FUNCTION: Returns seconds.
SYNTAX:Second(time)
ARGUMENTS:.
EXAMPLE:
RESULT:28
StrReverse()
FUNCTION: reverse row of string
SYNTAX:StrReverse(string)
ARGUMENTS:
EXAMPLE:
strTest="Thisisastest!!"
response.writeStrReverse(strTest)
%>
RESULT:!!tsetasisihT
Time()
FUNCTION: Returns system time.
SYNTAX:Time()
ARGUMENTS:.
EXAMPLE:
RESULT:9:58:28AM
Trim()
FUNCTION: Remove the spaces on the left and right sides of the string.
SYNTAX:Trim(string)
ARGUMENTS: stringisanyvalidstringexpression.
EXAMPLE:
strTest="Thisisastest!!"
response.writeTrim(strTest)
%>
RESULT:Thisisastest!!
UBound()
FUNCTION: Returns the maximum available subscript for the specified array dimension.
SYNTAX:Ubound(arrayname[, dimension>)
ARGUMENTS:dimensional(optional) specifies which dimension the upper bound of the integer is returned. 1 means the first dimension, 2 means the second dimension, and so on. If omitted
The default value is 1.
EXAMPLE:
i=Array("Monday","Tuesday","Wednesday")
response.writeUBound(i)
%>
RESULT:2
UCase()
FUNCTION: Returns the uppercase form of a string.
SYNTAX:UCase(string)
ARGUMENTS:
EXAMPLE:
strTest="Thisisastest!!"
response.writeUCase(strTest)
%>
RESULT:THISISATEST!!
VarType()
FUNCTION: Returns the value indicating the subtype of the variable
SYNTAX:VarType(varName)
ARGUMENTS:
EXAMPLE:
i=3
response.writevarType(i)
%>
RESULT:2 (number) See "asp constant" for details
WeekDay()
FUNCTION: Return to the day of the week.
SYNTAX: WeekDay(date[, firstdayofweek>)
ARGUMENTS:.
EXAMPLE:
d=#8/4/99#
response.writeWeekday(d)
%>
RESULT:4 (Wednesday)
WeekDayName()
FUNCTION: Returns the name of the day of the week.
SYNTAX: WeekDayName(weekday[,Abb[,firstdayofweek>>)
ARGUMENTS: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, that is, it is not abbreviated for each week
The name of the day.firstdayofweek refers to the value of the first day of the week
EXAMPLE:
d=#8/4/99#
response.writeWeekdayName(Weekday(d))
%>
RESULT:Wednesday
Year()
FUNCTION: Returns the current year.
SYNTAX:Year(date)
ARGUMENTS:
EXAMPLE:
RESULT:1999
The above is a detailed analysis of the usage of common functions of Asp. I believe you have understood it. For more related content, please continue to pay attention to the Wuxin Technology Channel.