The ASPError Object 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 'Call the GetLastError() method to trap the error dim objerr set objerr=Server.GetLastError() 'The variable objerr now contains the ASPError object response.write("ASP Code=" & objerr.ASPCode) response.write("<br />") response.write("Number=" & objerr.Number) response.write("<br />") response.write("Source=" & objerr.Source) response.write("<br />") response.write("Filename=" & objerr.File) response.write("<br />") response.write("LineNumber=" & objerr.Line) %> </body> </html> The ASPError Object's Properties (ASP 3.0) ASPCode The ASPCode property returns an error code generated by IIS. ASPDescription The ASPDescription property returns a detailed description of the error. 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 Description property returns a short description of the error.

File 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" & response.write("visit" & response.write("visit" & response.write("visit" & %> </body> </html> How to reverse a string? <html> <body> <% sometext = "Hello Everyone!" response.write(strReverse(sometext)) %> </body> </html> How to round a number? <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()) %>

name & "now<br />") trim(name) & "now<br />") ltrim(name) & "now<br />") rtrim(name) & "now")

</body> </html> Return a specified number of characters from left /right of a string <html> <body> <% sometext="Welcome to this Web" response.write(Left(sometext,5)) response.write("<br>") response.write(Right(sometext,5)) %> </body> </html> Replace a some characters in a string <html> <body> <% sometext="Welcome to this Web!!" response.write(Replace(sometext, "Web", "Page")) %> </body> </html> Call a procedure using vbscript in asp <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>