Skill | statement
One, on Error statements
The purpose of this statement is to enable or disable an error handler. The general usage is as follows:
On Error Resume Next
On Error GoTo 0
If the On Error Resume Next statement is not used in your code, the Run-time error that occurs will display an error message, and the execution of the code is terminated.
When you take it, however, the program continues to execute according to the statement following the statement that generated the error or the statement in the procedure that was last called (the procedure contains an on Error Resume Next statement). This statement can continue executing the program regardless of run-time errors, and you can then create an error-handling routine inside the procedure.
The On Error Resume Next statement becomes inactive when another procedure is invoked. Therefore, if you want to make internal error handling in a routine, you should execute the On Error Resume Next statement in each calling routine.
If you have enabled the On Error Resume Next fault handler, you can disable the error handler using On Error GoTo 0.
<script language=vbs>
On Error Resume Next
Err.Raise 6 ' generates an overflow error.
MsgBox ("Error #" & CStr (Err.Number) & "" & Err.Description)
Webjx.com ' missing object because WEBJX is a custom
MsgBox ("Error #" & CStr (Err.Number) & "" & Err.Description)
Err.com ' object does not support this property or method
MsgBox ("Error #" & CStr (Err.Number) & "" & Err.Description)
Err.Clear ' clears the error.
</script>
Note: To generate a run-time error in your code, use the Raise method of the Err object.
This situation is often seen in the debugger, such as debugging the following two programs will show.
1,err1.asp
<%err.raise 6%>
Technical information (for support staff)
Error type:
Microsoft VBScript run-time Error (0x800a0006)
Overflow
2,err2.asp
<%webjx.com%>
When it comes to debugging,
Technical information (for support staff)
Error type:
Microsoft VBScript run-time Error (0X800A01A8)
Missing object: ' WEBJX '
However, when you add On Error Resume next in the first line, you find no error prompts, indicating that internal error processing is complete.
But the following procedures were found
3,err3.asp
<%
On Error Resume Next
Webjx.com
On Error GoTo 0
Webjx.com
%>
Using the On Error GoTo 0, the error message is displayed, except that it is not the third line, but the webjx.com Error object in line fifth.
With the above examples, I believe you should have some understanding of this statement. Then look again.
Two, Option Explicit statement
The purpose of this statement is to force the requirement
an explicit declarationAll variables in the script.
The so-called explicit declaration is to declare all variables using Dim, Private, public, or REDIM statements. If you try to use an undeclared variable name in your program, an error occurs. Use this statement to avoid misspelled variable names that already exist. Using this statement can also avoid confusion for variables that are not scoped.
Of course, if you want to use Option Explicit, the statement must appear before any other statements in the script.
4,err4.asp
<%
Option Explicit ' forces a declaration variable to be displayed.
Dim MyVar ' declares a variable.
MyVar = 10 ' Declaring a variable does not produce an error.
MyInt = 10 ' does not declare a variable to produce an error.
Response.Write (MYINT)
%>
The error message is as follows:
Technical information (for support staff)
Error type:
Microsoft VBScript run-time Error (0X800A01F4)
Variable not defined: ' MyInt '
Plus: The ASP provides strong support for VBScript, seamless integration of VBScript functions, methods, which extend the existing functionality of the ASP is greatly facilitated. Since the concept of variable types has been blurred in ASP, many programmers are wont to declare VBScript variables (I am also-_-!, later) in the process of interacting ASP and VBScript, thus aggravating the server's resolution burden, thus affecting the server's response request speed.
For this reason, we can force a user to declare a variable in VBScript just as a variable declaration is enforced in VB. The implementation method is to place <% option explicit%> at the beginning of the ASP program. The practice also proves that using "Option Explicit" in ASP files can minimize the chance of program error and greatly improve overall performance.
In addition, the declared variables have a sequential trick, either at compile time or at run time. The declared variables are referenced in this order.
third, <% @LANGUAGE = "xxx" codepage= "936"%>
Generally divided into <% @LANGUAGE = "VBSCRIPT" codepage= "936"%> and <% @LANGUAGE = "JAVASCRIPT" codepage= "936"%> two kinds.
language= "VBSCRIPT"And
language= "JAVASCRIPT", stating that the programming scripts currently used by ASP are VBScript and JavaScript, respectively. It is generally stated in the first line of the procedure. When the script is declared, all of the following programs use all the syntax that conforms to the scripting language, which cannot be confused or error. When we write ASP, we generally do not qualify, because we often write different scripts on an ASP page, of course, at the expense of execution efficiency.
CodePage: Readable/writable. Integral type. Defines the code page that is used to display the content of a page in a browser. The code page is the numeric value of the character set, and different languages use different code pages. For example, the ANSI code page is 1252, the Japanese code page is 932, and the Simplified Chinese code page is 936. Under normal circumstances, when you upload a foreign web page space, or extract the database records and other garbled, this method is used to solve.