VBScript function table

xiaoxiao2021-03-05  53

ASP language features

1. Allows the use of VBScript or JavaScript simple script language and HTML can be combined in the file;

2. No need to compile, is executed by WebServer;

3. Compatible with any ActiveX Script;

4.aSP Original Code Will not pass to the client, the client is displayed is the execution result.

VBScript Common Function: 1. Numerical Function: ABS (NUM): Returns absolute value SGN (NUM): Num> 0 1; Num = 0 0; Num <0 -1; Judgment Numeri Positive Mini HEX (NUM): Return Ten The six-input value is directly represented: & HXX maximum 8-bit OCT (NUM): Return Eight-entered value directly: & oxx up to 8-bit SQR (NUM): Return to square root Num> 0int (NUM): Take INT (99.8) = 99; int (-99.2) = 100Fix (NUM): Fixing FIX (99.8) = 99; fix (-99.2) = 99Round (Num, N): Since the four rounds of decimal Round (3.14159, 3) = 3.142 Midpower number rounded Even Round (3.25, 1) = 3.2log (NUM): Take the log of E is the end of Num> 0exp (N): Take the N power of E usually use NUM ^ nsin (num): triangular function, Arc is value calculation (angle * PAI) / 180 = radians Con (Num); TAN (NUM); ATN (NUM)

2. String function: LEN (STR): Calculating string length Chinese character length is also one! MID (Str, Start Character, [Reading Length]): Intercept string intermediate sub-string Left (STR, NLEN): Jut from the left side of NLEN length sub-string Right (STR, NLEN): Accept NLEN from the right Length sub-string LCase (STR): String to lowercase UCase (STR): String transparent TRIM (STR): Removal string two end space Ltrim (STR): Remove the left space RTRIM (STR) on the string : Remove the right space of the string (Str, lookup string, replace string, [start character, alternative, comparison method]): Replace the string

Note: Default: Start character 1; alternative number is not limited; the comparison method is case sensitive (0)

INSTR ([Start Character,] STR, Find String [, Compare Method]): Detects whether to include a sub-string optional parameter, you need to return to the start position INSTRRREV (Str, lookup string [, start character] [ , Comparison Method]): Reverse detection Contains whether the sub-string returns start position Space (n): constructs N, String String (N, STR): Constructs a string consisting of N Str first characters Strreverse (STR): Reverse string split (STR, split string [, number of times] [, compare method]): Split string is the segmentation flag to convert a string to a character array optional parameter needs to be selected.

3. Data type conversion function: CINT (STR): Convert positive TRUE-1; false 0; date distance 1899/12/31 days; time in the morning, afternoon 1; CSTR (STR): Date Output format YYYY / MM / DD; Time Output Format AM / PM HH: MM: SSCLNG (STR): Similar CBOOL (NUM): NUM is not zero True; anti-falsecdate (STR): Conversion Date format 0: #am 12: 00:00 #; Positive distance 1899/12/31 days Date; floating point date Decimal time CByte (NUM): Num <255 Convert to byte CSNG (STR): Convert to single precision value CDBL (STR): Converted to a double precision numerical CCUR (STR): Convert to cash format 4. Time function: Date: Take system current date Time: Take the system Current time and date value DateTime Timer: Take the current time distance zero seconds Value, timer, calculated time difference dateadd (interval, interval value, date): estimate: Date DateDiff (Space, Date 1, Date 2): Calculation time difference date 2 - Date a datepart (interval unit, date): Interval Date Split Unit Value DateSerial (Date): Output Date (Calculation) TimeSerial (Time): Output Time Value (Calculated by Sequence): Remove String Date Value TimeValue (DateTime): Take the character String time value weekday (date): Calculate the month of MonthName (Date): Output Monthly Name Year (DateTime): Intercepting Month (DateTime): Intercepting Day Hour (DateTime): Intercept Hours Minute (DATETIME): Intercept minute second (datetime): intercept second

5. Other functions: array (unit, ..): Dynamically generate an array ASC (STR): Output string first character ASCII code CHR (ASC): Convert ASCII as character ENTER: CHR (13) & chr (10) Filter (Array Name, Key String, [, Compare] [, Comparison Method]):

Make a new array in the character string array (default) [contain] [contain] FALSE to take the element that does not contain

OIN (ARRAYNAME): Connect the elements of the array into string ubound (arrayname [, dimension]): Acquired an array corresponding dimension of the upper LBound (ArrayName [, dimension]): The lower boundary of the corresponding dimension of the array is generally 0randmize N: Start random seed RND (N): Number of random numbers, n> 0 or empty, sequence, N <0, random value, n = 0, production is the same as the previous random value number

Take the random positive number C between A and B, formula: c = int ((B-A 1) * RND A) Condition (B> a)

Substragroom and custom functions SUB STRSUBNAME FUNCTION STRFUNNAME (arg [1], ..) Subprogram function body exit subway jump out of the exit function in the End SUB STRFUNNAME = VALUE Return Value

END FUNCTION

[Call] strsubname reference subroutine var = strfunname (arg [1], ..) reference function

Subprints and custom functions can be recursively called;

ASP six major objects common statement demonstration:

Response:

Response.write strvar / "string": Write the parameter value or string to the web page is equivalent to embedding <% = strvar / "string"%> response.end: Stop page compile in the HTML tag, and outputs the content output to Browser Response.buffer = true | false: Whether the cached settings are used when compiling, generally set the response.flush on the page header: Forced output page Compiled part content Response.clear: Clear the data in the buffer Response.Redirect URL: Stop page Compile or output, reproduced the specified page response.isClientConnected: Return true | false, detect if the user is still in connection status response.charset: set the page encoding type, response.contentType [= contentType]: Set the page file type, with response.expires [= number]: set the page failure time, unit minutes response.expiresabsolute [= [= Date] [TIME]]: Set the absolute time of the page failure

Response.status = statusdescription: Settings page status description

REQUEST:

Request ("passstrname": read web page transfer values, including forms and PassstrName = value & passStrName_n = value_n

Request [.collection | Property | Method] (Variable)

Request.QueryString ("PassStrName": Read the form value passed by the get method and? Passstrname = value

Request.QueryString (varible) [(index) .count]

Request.form ("PassStrName"): Read the value of the pure table single field passing from the Post method

Request.form (Parameter) [(index) .count]

Request.servervaribles: Read the client system environment variable, see Reference

Request.binaryRead (count): Read the transfer value of the specified byte number

Request.totalbytes: The length of the query body, in bytes, read only

Note: The same name form, such as: checkbox, if there is a number of values, pass the form, right, strname = value1, value2, ... You need to split the value of each value with the SPLIT function Multiple, similar to checkbox, the value of Textarea can include charming characters Using Replace to
to meet the format requires session: (user global variable)

Session ("SESNAME") = value: Store session variable values, or reads this value session ("sesname") = Empty: Decluders whether the session value exists. ISempty (SESSION ("SESNAME")) = True | FALSE: Two methods of judging if the session value exists session.timeout = Num: Set the existence of the session variable, unit minutes session.abandon: Clear all session variables session.SessionID: session variable ID serial number, read-only

Application: (Application Global Variable) Application ("AppName") = value: Store Application Variables, or reads this value Application ("AppName") = EMPTY: Determines whether there are two methods that the application value exists. ISempty (Application "Appname") = true | false: Determines whether the Application value exists Application.lock: Application Variable value lock to prevent the variable value application.unlock: Application Variable value unlock, allowing change to change the variable value Note: session Application variables can be used to store arrays and system objects, and the reference method is that the variable name is equivalent to an array name.

But you can't change your value directly, you need to use the temporary array to modify the value, then assign it to the session and application variables.

Global.asa file structure: <% @ language = "vbscript"%> <% sub applic_onstart ... End subs subsection_onstart ... End subsis_onnd ... End Sub%>

Server:

Server.mappath ("fileurl"): The server site absolute address of the mapping file name, Path = Server.mAppath (. /) Can get the virtual directory root path server.htmlencode ("string"): Convert to directly display the HTML format Server.urlencode ("string", such as: <,> and so on: Convert to browser address encoding set var = server.creatobject ("objName"): Create an object variable server.scripttimeout = Numseconds: ASP program page execution Time limit, in seconds

Cookies: Stored in the user's local variable, each cookie's maximum byte 4KB, up to 300 cookie 1.2MBRESPONSE.COOKIES ("strcookiename") = value: Store the cookie variable, you can also read this value response .Cookies ("strcookiename") = "": Judging whether it is empty response.cookies ("strcookiename"). Expires = Date: Variable validity period, in terms of sky, less than the current time to expire Response.Cookies (cookie " .Attribute]): Standard syntax ObjectContext control ASP transaction ObjectContext.ontransactionabort: The abandoned transaction event is excited, ObjectContext.ontransactionCommit: ObjectContext.ontransActionCommit: The successful transaction event is excited, ObjectContext occurs after the script is completed .SETABORT: Explicitly waive one transaction ObjectContext.setComplete: Overwrite any call to call ObjectContext.Setabort Method MsgBox "string" / strname: VBScript prompt box

The list of Onsubmit events: written in the same page, FUNCTION FORMNAME_ONSUBMIT () .. FormName_onSubmit = true / false..end function,

The page will perform the statement before commit and determine if the submission task is completed according to the return value.

Database connection string example: access2000: conn.Open "provider = microsoft.jet.Oledb.4.0; data source =" & server.mappath ("dbase / liuyan.mdb") conn.jet "provike" provike "provike .4.0; Data Source = "& Server.mappath (" DBASE / Liuyan.mdb ") &"; password = admin "RecordSet.open" Data Table Name ", CON, 2, 2SQLServer2000: Conn.open" provider = sqloledb. 1; user ID = sa; password = admin; initial catalog = pubs; data source = server / garlmrm "conn.open" provider = sqloledb; data source = hyserver; uid = sa; pwd =; database = pubs "Record.Open Strsql, CONN, 2, 2

DBASE: (?) Conn Open "driver = {Microsoft DBase Driver}; SourceType = DB; Sourcedb =" & Server.mappath ("Directory Name") Recordset.Open Strsql, CONN, 2, 2

FoxBase: conn open "driver = {Microsoft Visual FoxPro Driver}; SourceType = DBF; SOURCEDB =" & Server.mappath ("Directory Name) Recordset.open DBF File Name or SELECT statement, conn, 2, 2, 2conn open" driver = {Microsoft Visual FoxPro Driver}; SourceType = DBC; SourceDB = "& Server.mappath (" DBC Database File Name ") RecordSet.open DBF file name or SELECT statement, conn, 2, 2Excel: conn open" driver = {Microsoft Excel Driver (* .xls)}; DBQ = "& Server.mappath (" XLS file name ") Recordset.open" Select * from ["& Sheet &" $], conn, 2, 2

Note: Use the DBF, DBC, Excel database, the following points should be Note: Excel database can only read, add records, modify records, but cannot delete records; DBF, DBC can read records, add records, delete records, modify records However, when increasing records, no field value can be empty, thereby seeing the limitations, so as much as possible MDB or SQL database

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

New Post(0)