ASP CreateObjectMethod
Complete Server Object Reference Manual
The CreateObject method creates an instance of an object.
Note:Objects created using this method have page scope. That is, after the current ASP page finishes processing, the server will automatically destroy these objects. To create objects with session or application scope, you can use the <object> tag in the Global.asa file and set the session or application SCOPE attribute, or you can store the object in a session or application variable.
Syntax
| Parameter | Description |
|---|---|
| progID | Required. The type of object to create. |
Example 1
This example creates an instance of the server component MSWC.AdRotator:
Set adrot=Server.CreateObject("MSWC.AdRotator")
%>
Example 2
When the session ends, the object stored in the session variable will be destroyed. However, you can also destroy the object by setting the variable to Nothing or a new value:
Session("ad")=Nothing
%>
Or:
<%
Session("ad")="a new value"
%>
Example 3
You cannot create an object instance with the same name as a built-in object. For example, the following script will return an error:
Set Application=Server.CreateObject("Application")
%>
Complete Server Object Reference Manual Other Extensions