1. Numeric functions:
ABS (Num): returns the absolute value.
SGN (Num): num> 0 1; num = 0 0; num <0-1; Positive and Negative values
Hex (Num): returns the hexadecimal value for direct representation: & hxx maximum 8 bits
Oct (Num): returns the octal value and indicates the maximum 8 bits of & oxx
Sqr (Num): returns the square root num> 0
INT (Num): integer int (99.8) = 99; int (-99.2) = 100
Fix (Num): Get the integer fix (99.8) = 99; fix (-99.2) = 99
Round (Num, n): rounded to the decimal place round (3.14159, 3) = 3.142 the midpoint value is rounded to the nearest even round (3.25, 1) = 3.2
Log (Num): returns the base-e logarithm num> 0.
Exp (n): The N power of e is usually num ^ n.
Sin (Num): trigonometric function, which is calculated in radians (angle * PAI)/180 = radian con (Num); Tan (Num); ATN (Num)
2. String functions:
Len (STR): calculates the length of a string. The length of a Chinese character is also counted as one!
Mid (STR, start character, [read length]): intercept the middle substring of the string
Left (STR, nlen): truncates the nlen substring from the left.
Right (STR, nlen): truncates the nlen length substring from the right.
Lcase (STR): converts a string to lowercase.
Ucase (STR): converts a string to uppercase.
Trim (STR): removes spaces at both ends of the string.
Ltrim (STR): removes spaces on the left of the string.
Rtrim (STR): removes spaces on the right of the string
Replace (STR, search string, replace string, [Starting character, replacement times, comparison method]): replace string
Note: Default Value: Start character 1; unlimited number of replacements; Case sensitivity (0)
Instr ([start character,] STR, search string [, comparison method]): checks whether a sub-string contains optional parameters. You must select the return start position at the same time.
Reverse Rev (STR, query string [, start character] [, comparison method]): reverse detection of whether a substring is included
Space (n): string that constructs n Spaces
String (n, STR): constructs a string consisting of the first character of n str
Strreverse (STR): reverse string
Split (STR, split string [, times] [, comparison method]): Convert string into character array using the separator string. Optional parameters must be selected at the same time
3. Data type conversion functions:
CINT (STR): Convert positive values to true-1; false 0; Date distance to 1899/12/31; time in the morning segment 0; afternoon segment 1;
CSTR (STR): Date output format: yyyy/mm/DD; Time Output Format: AM/PM hh: mm: SS
Clng (STR): similar to CIN ()
Cbool (Num): num is not zero. True; false
Cdate (STR): Format of the conversion date 0: # Am 12:00:00 #; date with a positive number ranging from 1899/12/31 days; floating point date + decimal time
Cbyte (Num): num <255 to bytes
Csng (STR): convert to a single-precision value
Cdbl (STR): convert to a double-precision value
Ccur (STR): Convert to cash format
4. Time functions:
Date: the current date of the system.
Time: the current system time.
Now: The datetime type of the current system time and date value.
Timer: the time difference between the current time and the zero second value. The timer can calculate the time difference.
Dateadd (interval unit, interval value, date): Calculate the adjacent date
Datediff (interval unit, date 1, date 2): Calculate time difference date 2-date 1
Datepart (interval unit, date): calculates the interval unit value of the date.
Dateserial (date): Output date value (calculated by sequence)
Timeserial (time): Output Time Value (calculated by sequence)
Datevalue (datetime): extracts the date value from the string.
Timevalue (datetime): retrieves the time value from the string.
Weekday (date): Calculate the day of the week
Monthname (date): name of the output month
Year (datetime): specifies the year to be truncated.
Month (datetime): truncate month
Day (datetime): truncate day
Hour (datetime): hour intercepted
Minute (datetime): capture minutes
Second (datetime): truncation second
5. Other functions:
Array (unit,...): dynamically generates an array
ASC (STR): the ASCII code of the first character of the output string.
CHR (ASC): Convert ASCII to enter: CHR (13) & CHR (10)
Filter (array name, key string, [, including] [, comparison method]):
Store the elements containing key strings in the string array into a new array (default). If [include] is false, the uncontained elements are obtained.
Join (arrayname): concatenates elements in the array into strings.
Ubound (arrayname [, dimension]): obtains the upper bound of the corresponding dimension of the array.
Lbound (arrayname [, dimension]): the lower bound to obtain the corresponding dimension of the array is generally 0.
Randmize N: Start Random Seed
RND (n): obtain a random number. n> 0 or null. Obtain the next random value of the sequence. n <0. The random value is the same. n = 0, produce the same number as the previous random Value
Take random positive numbers C between A and B, formula: c = int (B-A + 1) * RND + a) condition (B>)
Subprograms and user-defined functions
Sub strsubname function strfunname (ARG [1],...)
Subroutine body
Exit sub
End sub strfunname = value return value
End Function
[Call] strsubname reference subroutine Var = strfunname (ARG [1],...) Reference Function
Subprograms and user-defined functions can be called recursively;
Examples of common statements for six ASP objects:
Response:
Response. Write strvar/"string": writing a parameter value or string to a webpage is equivalent to embedding <% = strvar/"string" %> in an HTML Tag.
Response. End: Stop page compilation and output the compiled content to the browser.
Response. Buffer = true | false: whether to use cache settings during page compilation. This is generally set in the page header.
Response. Flush: forces the output of partially compiled page content
Response. Clear: clears data in the buffer.
Response. Redirect URL: Stop page compilation or output and reprint the specified page
Response. isclientconnected: returns true | false to check whether the user is still connected.
Response. charset (charsetname): sets the page encoding type, that is, <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
Response. contenttype [= contenttype]: Set the page file type, same as above
Response. expires [= number]: Set the page expiration time, in minutes
Response. expiresabsolute [= [date] [time]: sets the absolute time when the page fails.
Response. Status = statusdescription: sets the page status description.
Request:
Request ("passstrname"): Read the webpage transfer value, including the form and? Passstrname = Value & passstrname_n = value_n form
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 form field passed by the POST method.
Request. Form (parameter) [(INDEX). Count]
Request. servervaribles (server environment variable): Read the environment variables of the client system. For details, see references.
Request. binaryread (count): Read the transfer value of the specified number of bytes
Request. totalbytes: the length of the query body, in bytes, read-only
Note: For a form with the same name, for example, if checkbox has multiple values, the transfer form is right, strname = value1, value2,... you need to use the split function to split the values.
The Select form of multiple is similar to the checkbox. The value of textarea can contain line breaks and be converted to <br> using replace to meet the format requirements.
Session: (User global variables)
Session ("sesname") = value: stores the session variable value, which can also be read.
Session ("sesname") = empty: two methods to determine whether the session value exists
Isempty (Session ("sesname") = true | false: two methods to determine whether the session value exists
Session. Timeout = num: Set the validity period of the session variable, in minutes
Session. Abandon: Clear all session variable values
Session. sessionid: Id serial number of the session variable, read-only
Application :( global variables of the Application)
Application ("appname") = value: stores the value of the application variable. You can also read this value.
Application ("appname") = empty: two methods to determine whether the application value exists
Isempty (Application ("appname") = true | false: two methods to determine whether the application value exists
Application. Lock: the value of the application variable is locked to prevent changing the value at the same time.
Application. Unlock: Unlock the value of the application variable, allowing you to change the value.
Note: Both session and Application variables can be used to store arrays and system objects. The reference method is that the variable name is equivalent to the array name,
However, the value cannot be changed directly. You need to use the temporary array to modify the value and then assign it to the session and Application variables.
Structure of the global. Asa file: <% @ Language = "VBScript" %>
<% Sub application_onstart... end sub
Sub application_onend... end sub
Sub session_onstart... end sub
Sub session_onend... end sub %>
Server:
Server. mappath ("fileurl"): the absolute address of the server site mapped to the file name. Path = server. mappath (./) can obtain the root path of the virtual directory.
Server. htmlencode ("string"): converts to HTML-formatted strings, such as: <,>.
Server. urlencode ("string"): Convert to browser address encoding.
Set Var = server. creatobject ("objname"): creates an object variable.
Server. scripttimeout = numseconds: time limit for executing ASP program pages, in seconds
Cookies: temporary variables stored on the user's local machine. The maximum size of each cookie is 4 kb. A maximum of 300 cookies can be 1.2 MB.
Response. Cookies ("strcookiename") = value: stores the cookie variable value, which can also be read.
Response. Cookies ("strcookiename") = "": determines whether it is empty.
Response. Cookies ("strcookiename"). expires = Date: The variable validity period, in days. The variable is invalid immediately when it is less than the current time.
Response. Cookies (cookie [(key). Attribute]): standard syntax
Objectcontext controls ASP Transaction Processing
Objectcontext. ontransactionabort: triggered by the abandoned Transaction Processing Event, which occurs after the script completes processing.
Objectcontext. ontransactioncommit: triggered by a successful transaction processing event.
Objectcontext. setabort: explicitly discard a transaction
Objectcontext. setcomplete: overwrite any previous call to the objectcontext. setabort method.
Msgbox "string"/strname: VBScript prompt box
Form onsubmit event: Write function formname_onsubmit ()... formname_onsubmit = true/false... end function on the same page,
The page executes the statement before submission and determines whether the task is submitted based on the returned value.
Database connection string example:
Access2000:
Conn. Open "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath ("DBASE \ liuyan. mdb ")
Conn. Open "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath ("DBASE \ liuyan. mdb") & "; Password = admin"
Recordset. Open "data table name", Conn, 2, 2
Sqlserver2000:
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"
Recordset. 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
Conn 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, 2
Excel:
Conn open "driver = {Microsoft Excel Driver (*. xls)}; DBQ =" & server. mappath ("xls file name ")
Recordset. Open "select * from [" & sheet & "$]", Conn, 2, 2
Note: When Using DBF, DBC, and Excel databases, note the following: Excel databases can only read, add, and modify records, but cannot delete records;
DBF and DBC can read, add, delete, and modify records. However, when adding a record, the value of any field cannot be blank.
It can be seen that the limitations are great, so try to use MDB or SQL database as much as possible.