ASP function

xiaoxiao2021-03-06  56

The ASP function is similar to VBScript, and there are some common functions.

Array () function Returns an array expression array (list) allows data types: characters, numbers

Example:

<% DIM myarray () for i = 1 to 7redim preserve myarray (i) MyArray (i) = weekdayname (i) Next%>

Return Result: Create a array of 7 elements with MyArray

MyArray ("Sunday", "Monday", ... "SATURDAY") CINT () function converts an expression into a digital type expression CINT (Expression) Allow data type: Any valid character can be instance: <% f = "234" RESPONSE.WRITE CINT (f) 2%> Return Result: 236 Transformation Character "234" is a number "234", if the string is empty, return 0 value creteObject () function establishment and return An instance of a registered ActiveX component. Expression CreateObject (ObjName) Allow Data Types: ObjName is a name for any valid, registered ActiveX component.

Example: <%

Set con = Server.createObject ("AdoDb.Connection")

%>

CSTR ()

A function transforms an expression as a string.

Expression CSTR (Expression)

Allow data types: Expression is any valid expression.

Example: <%

S = 3 2

Response.write "THE Return Results IS:" & CSTR (s)

%>

Return Result: Transforming Number "5" is character "5".

Date ()

The function returns the current system date.

Expression Date ()

Allow data types: None.

Example: <% = DATE%>

Return Results: 9/9/00

Dateadd ()

The function returns a changed date.

Expression Dateadd (TimeInterval, Number, Date)

Allow data type: TimeInterval is the time interval to add; number is amount of time interval to add; and date is the starting date.

Example: <%

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 Results: 9/9/00

3:34:45 PM

"m" = "month";

"d" = "day";

IF currentdate is in time format the,

"h" = "hour";

"s" = "second";

Datediff ()

The function returns the difference between the two dates.

Expression Datediff (TimeInterval, Date1, Date2 [, Firstdayofweek [, Firstweekofyear]])

Allow data type: TimeInterval indicates the type of the separation time, such as "M" means "month". Example: <%

FromDate = # 9/9/00 #

TODATE = # 1/1/2000 #

Response.write "There Are" & _

Datediff ("D", FromDate, Todate & _

Days to Millenium from 9/9/00. "

%>

Returns: 150 days from 9/9/00 to 2000.

Day ()

The function returns a month of the day.

Expression Day (date)

Allow data types: Date is any valid date.

Example: <% = DAY (# 9/9/00 #)%>

Return Result: 4

Formatcurrency ()

Function returns an expression, this expression has been formatted as a currency value

Expression Formatcurrency (Expression [, DIGIT [, LeadingDigit [, Paren [, GroupDigit]]]])

Allow data types: DIGIT indicates the value of the number of digits on the right side of the decimal point. The default value is -1, indicating the area setting of the computer; the LeadingDigit tri-state constant indicates whether the zero in front of the small numerical point is displayed.

Example: <% = Formatcurrency (34.3456)%>

Return Results: $ 34.35

Formatdatetime ()

The function returns the expression. This expression has been formatted as a date or time.

Expression Formator (Date, [, NamedFormat])

Allow data types: NamedFormat indicates the value of the date / time format used, if omitted, use VBGeneLDate.

Example: <% = formatdatetime ("09/9/00", vblongdate)%>

Return Results: Sunday, September 09, 2000

FormatNumber ()

The function returns an expression that is formatted to a value.

Expression FormatNumber (Expression [, DIGIT [, LeadingDigit [, Paren [, GroupDigit]]])

Allow data types: DIGIT indicates the value of the number of digits on the right side of the decimal point. The default is -1, indicating the area setting of the computer. LeadingDigit i indicates the value of the display bits on the right side of the decimal point. The default is -1, indicating the area setting of the computer. PAREN indicates the value of the number of digits on the right side of the decimal point. The default is -1, indicating the area setting of the computer. GroupDigit i indicates the value of the number of digits on the right side of the decimal point. The default is -1, indicating the area setting of the computer. .

Example: <% = FormatNumber (45.324567, 3)%>

Return Results: 45.325

Formatpercent ()

The function returns the expression that is formatted to have a percentage of the percentage of the tail (multiplying 100). (%)

Expression Formatpercent (Expression [, DIGIT [, LeadingDigit [, Paren [, GroupDigit]]]])

Allow data types: Ib.

Example: <% = Formatpercent (0.45267, 3)%>

Return Result: 45.267%

Hour ()

The function returns hours number at 24.

Expression Hour (TIME)

Allow data types:

Example: <% = Hour (# 4: 45: 34 pm #)%>

Return Results: 16 (Hour Has Been Converted to 24-Hour System)

INSTR ()

The function returns the character or string where the first appearance in another string.

Expression INSTR ([START,] STRTOBESEARCHED, STRSEARCHFOR [, Compare])

Allow data types: start for the starting value of the search, STRTOBESEARCHED accepts the search for string strSearchFor to search the character. Compare comparison method (detailed view ASP constant)

Example: <%

strText = "this is a test !!"

POS = INSTR (strText, "a")

Response.write POS

%>

Return Result: 9

INSTRREV ()

The function is the same, just from the last search of the string

Expression INSTRREV ([Start,] Strtobesearched, StrsearchFor [, Compare])

Allow data types: Ib.

Example: <%

strText = "this is a test !!"

POS = INSTRREV (Strtext, "S")

Response.write POS

%>

Return Result: 13

Int ()

The function returns a numeric type and does not go all over.

Expression INT (Number)

Allow data types:

Example: <% = INT (32.89)%>

Return Result: 32

Isarray ()

The function determines whether an object is an array and returns the Boolean value.

Expression Isarray (Name)

Example: <%

strTest = "Test!"

Response.write isarray (StRTEST)

%>

Return Result: False

Isdate ()

The function judges whether or not the object is the date, return to Boolean

Expression isdate (Expression)

Example: <%

strTest = "9/4/2000"

Response.write isdate (StRTEST)

%>

Return Result: True

ISempty ()

The function determines whether an object is initialized and returns the Boolean value.

Expression ISEMPTY (EXPRESSION)

Example: <%

DIM I

Response.Write ISempty (i)

%>

Return Result: True

Isnull ()

The function determines whether an object is empty and returns the Boolean value.

Expression ISNULL (EXPRESSION)

Example: <%

DIM I

Response.write isnull (i)

%>

Return Result: False

Isnumeric ()

The function determines whether an object is a number and returns the Boolean value.

Expression ISNUMERIC (EXPRESSION)

Example: <%

i = "345"

Response.write isnumeric (i)

%>

Return Result: True

Even if the number adds quotation marks, ASP still thinks it is a number.

IsObject ()

The function determines whether an object is an object and returns the Boolean value.

Expression ISOBJECT (EXPRESSION)

Example: <%

Set con = Server.createObject ("AdoDb.Connection")

Response.Write IsObject (con)

%>

Return Result: True

Lbound ()

The function returns the minimum available subscript of the specified array dimension. Expressions LBound (ArrayName [, Dimension])

Example: <%

i = array ("Monday", "Tuesday", "Wednesday")

Response.write lbound (i)

%>

Return Result: 0

Lcase ()

Function Returns the lowercase form of the string

Expression LCASE (String)

Example: <%

strTrtest = "this is a test!"

Response.write Lcase (StRTEST)

%>

Return Result: this is a test!

Left ()

The function returns a character (including Changth characters) previously character (including Changth characters) on the left side of the string.

Expression Left (String, Length)

Example: <%

strTrtest = "this is a test!"

Response.write Left (strTest, 3)

%>

Return Result: THI

Len ()

The function returns the length of the string.

Expression Len (String | VarName)

Example: <%

strTrtest = "this is a test!"

Response.write len (strTest)

%>

Return results: 15

Ltrim ()

The function removes the space left on the string.

Expression Ltrim (String)

Example: <%

strTrtest = "this is a test!"

Response.write Ltrim (StRTEST)

%>

Return Result: this is a test!

MID ()

The function returns a string of specific lengths (starting from START, length length).

Expression MID (String, Start [, Length])

Example: <%

Strtest = "this is a test! Today is monday."

Response.write Mid (Strtest, 17, 5)

%>

Return Result: Today

Minute ()

The function returns time for time.

Expression Minute (TIME)

Example: <% = minute (# 12: 45: 32 pm #)%>

Return Result: 45

Month ()

Function returns the date.

Expression Month (Date)

Example: <% = MONTH (# 08/04/99 #)%>

Return Result: 8

Monthname ()

Function returns the specified month

Expression MONTHNAME (Month, [, ABB])

Example: <% = monthname (MONTH (# 08/04/99 #))%>

Return Result: August

Now ()

Function returns system time

Expression now ()

Example: <% = no%>

Return Results: 9/9/00 9:30:16 AM

Right ()

The function returns the character (including Changth characters) before the string of the first side character (including Changth characters).

Expression Right (String, Length)

Example: <%

strTest = "this is an test!"

Response.write Right (strTest, 3)

%>

Return Result: ST!

RND ()

The function produces a random number.

Expression RND [(NUMBER)]

Example: <%

Randomize ()

Response.write rnd ()

%> Return Result: Number of any one between 0 and 1

Round ()

The function returns the value of the pointing number to the number of points.

Expression Round (Expression [, nuMright])

Example: <%

I = 32.45678

Response.write Round (i)

%>

Return Result: 32

RTRIM ()

The function removes the string on the right side of the string.

Expression RTRIM (String)

Example: <%

strTest = "this is a test !!"

Response.write Rtrim (StRTEST)

%>

Return Result: this is a test !!

Split ()

The function segments a string and returns the segmentation result

Expression split (s [, d])

Example: <% v = split (a, b, c)

For i = 0 to Ubound (V)

Response.write v (i)

NEXT

%>

Return Result: A B C

SECOND ()

The function returns second.

Expression SECOND (TIME)

Example: <% = second (# 12: 34: 28 pm #)%>

Return Result: 28

Strreverse ()

Function refrigerated string

Expression Strreverse (String)

Example: <%

strTest = "this is a test !!"

Response.Write Strreverse (StRTEST)

%>

Return Result: !! Tset A SI SIHT

Time ()

The function returns to the system time.

Expression TIME ()

Example: <% = Time%>

Return Results: 9:58:28 AM

Trim ()

The function removes the space around the string.

Expression TRIM (String)

Example: <%

strTest = "this is a test !!"

Response.write Trim (StRTEST)

%>

Return Result: this is a test !!

Ubound ()

The function returns the maximum available subscript of the specified array dimension.

Expression Ubound (ArrayName [, Dimension])

Example: <%

i = array ("Monday", "Tuesday", "Wednesday")

Response.write ubound (i)

%>

Return Result: 2

Ucase ()

The function returns the uppercase of the string.

Expression ucase (String)

Allow data types:

Example: <%

strTest = "this is a test !!"

Response.write ucase (StRTEST)

%>

Return Result: this is a test !!

VARTYPE ()

Function Returns the value indicating the variable quantum type

Expression Vartype (VarName)

Example: <%

i = 3

Response.write Vartype (i)

%>

Return Result: 2 (Digital) See "ASP constant" for details

Weekday ()

The function returns in the first few days of the week.

Expression Weekday (Date [, Firstdayofweek])

Example: <%

D = # 9/9/00 #

Response.write weekday (d)

%>

Return Result: 4 (Wednesday)

WeekdayName ()

The function returns the name of the first few days.

Expression WeekdayName (Weekday [, ABB [, Firstdayofweek]]) Instance:

<%

D = # 9/9/00 #

Response.write weekdayname (Weekday (D))

%>

Return Result: Wednesday

Year ()

The function returns the current year.

Expression Year (Date)

Example: <% = year (# 9/9/00 #)%>

Return Results: 1999

Chang (ASP) code set with author Jin: webthang.co.uk display the page load time

The zebra crossing in the field is displayed in the top 20 characters before and at the end, "..." If the motion picture is empty, use the default picture instead if the data is empty, use the default prompt information instead ● Display page loading time

Add the following code at the top of the page:

<% DIM STRSTARTTIMEDIM StrendTime

StrstartTime = Timer 'starts%>

The end of the page (the same page) Add:

<% 'Loaded at STRENDTIME = Timer

Response.write ("page load time:")

Response.Write FormatNumber (StrendTime - StrstartTime, 4) Response.write ("Second.")%>

● Zebra line in repeated domain

<% 'This module is placed outside DIM RecordCounterRecordCounter = 0% from the repetition domain.

tag in the repeating domain is replaced with this module' this module based on CSS to change the cell background color, you can also set the background color directly to achieve zebra crossing recordcounter = RecordCounter 1IF RecordCounter MOD 2 = 1 ThenResponse.write "Altrow1" Elseresponse.write "Altrow2" End IF%>

● The first 20 characters of the string are displayed and add "..." at the end.

<% DIM CUTSHORTSHORT = rsYourRecordSet.fields.item ("Yourfield"). ValueResponse.write Left (Cutshort, 20) & "........"%>

● If the dynamic picture is empty, use the default picture instead

<% DIM PICSHOWPICSHOW = rsShowHide.fields.Item ("shmainpix"). Valueif PicShow <> "" "> > < % ELSE%> <% end if%>

● If the data is empty, replace it with the default prompt information.

<% DIM strshowhideStrshowHide = rsyourrecordset.fields.Item ("YourDatafield"). Valueif StshowHide <> "" "" "" Data is empty <% end if%>

转载请注明原文地址:https://www.9cbs.com/read-113693.html

New Post(0)