Professional Documents
Culture Documents
The ASPError object is implemented in ASP 3.0 and it is only available in IIS5.
The ASP Error object is used to display detailed information of any error that occurs in scripts in an
ASP page. The ASPError object is created when Server.GetLastError is called, so the error
information can only be accessed by using the Server.GetLastError method.
Example
<html>
<body>
<%
'The following line creates an error
dim i for i=1 to 1 next
ASPCode
ASPDescription
Category
The Category property returns the source of the error (Was the error generated by IIS? A scripting
language? Or a component?).
Column
The Column property returns the column position within the ASP file that generated the error.
Description
The File property returns the name of the ASP file that generated the error.
Line
The Line property returns the number of the line within the ASP file that generated the error.
Number
The Number property returns the standard COM error code for the error.
Source
The Source property returns the actual source code of the line where the error occurred.
ASPError.ASPCode()
ASPError.ASPDescription()
ASPError.Category()
ASPError.Column()
ASPError.Description()
ASPError.File()
ASPError.Line()
ASPError.Number()
ASPError.Source()
Example
<%
dim objErr
set objErr=Server.GetLastError()
response.write("ASPCode=" & objErr.ASPCode)
response.write("<br />")
response.write("ASPDescription=" & objErr.ASPDescription)
response.write("<br />")
response.write("Category=" & objErr.Category)
response.write("<br />")
response.write("Column=" & objErr.Column)
response.write("<br />")
response.write("Description=" & objErr.Description)
response.write("<br />")
response.write("File=" & objErr.File)
response.write("<br />")
response.write("Line=" & objErr.Line)
response.write("<br />")
response.write("Number=" & objErr.Number)
response.write("<br />")
response.write("Source=" & objErr.Source)
%>
Case conversion
<html>
<body>
<%
name = "Bill Gates"
response.write(ucase(name))
response.write("<br>")
response.write(lcase(name))
%>
</body>
</html>
Trim a string
<html>
<body>
<%
name = " W3Schools "
response.write("visit" & name & "now<br />")
response.write("visit" & trim(name) & "now<br />")
response.write("visit" & ltrim(name) & "now<br />")
response.write("visit" & rtrim(name) & "now")
%>
</body>
</html>
<html>
<body>
<%
sometext = "Hello Everyone!"
response.write(strReverse(sometext))
%>
</body>
</html>
<html>
<body>
<%
i = 48.66776677
j = 48.3333333
response.write(Round(i))
response.write("<br>")
response.write(Round(j))
%>
</body>
</html>
A random number
<html>
<body>
<%
randomize()
response.write(rnd())
%>
</body>
</html>
<html>
<body>
<%
sometext="Welcome to this Web"
response.write(Left(sometext,5))
response.write("<br>")
response.write(Right(sometext,5))
%>
</body>
</html>
<html>
<body>
<%
sometext="Welcome to this Web!!"
response.write(Replace(sometext, "Web", "Page"))
%>
</body>
</html>
<html>
<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>
<body>
<p>
You can call a procedure like this:
</p>
<p>
Result: <%call vbproc(3,4)%>
</p>
<p>
Or, like this:
</p>
<p>
Result: <%vbproc 3,4%>
</p>
</body>
</html>