O'Reilly logo

VBScript in a Nutshell by Ron Petrusha, Paul Lomax, Matt Childs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Set Statement

Syntax 1

Set objectvar = {[objectexpression | newclassname1 Nothing}
objectvar

Use: Required

Data Subtype: Object

The name of the object variable or property.

objectexpression

Use: Optional

Data Subtype: Object

An expression evaluating to an object.

new

Use: Optional

Type: Keyword

Creates a new instance of an object defined using the Class...End Class construct.

classname

Use: Required

Data Subtype: String literal

The name of the class defined by the Class...End Class construct to be instantiated.

Nothing

Use: Optional

Type: Keyword

Assigns the special datatype Nothing to objectvar, thereby releasing the reference to the object.

Syntax 2

Set object.eventname = GetRef(procname)
object.eventname

Use: Required

Type: Event

The name of an object event that, when fired, causes the code in procname to execute.

procname

Use: Required

Type: String literal

The name of the procedure that serves as the event handler for object.eventname.

Description

Assigns an object reference to a variable or property. Its second syntax, using the GetRef function defines an event handler for an event; this is discussed in the GetRef function entry.

Rules at a Glance

  • objectvar doesn’t hold a copy of the underlying object; it simply holds a reference to (that is, the address of) the object.

  • If the New keyword is used, a new instance of the class is immediately created and its Class Initialize event fires. This applies only to classes defined using the Class...End Class construct.

  • All classes defined by the

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required