Live Demo

VBScript Class Objects

Create reusable objects with properties, methods, events

Person Class

A class with private fields, property get/let, methods, and constructor.

p.NameAlice
p.Age25
p.Greet()Hello, my name is Alice and I am 25 years old.
p.IsAdult()True

Multiple Instances

Each instance has independent state.

p1 (Bob)p2 (Charlie)
NameBobCharlie
Age1742
IsAdultFalseTrue

Calculator Class

Stateful object with operations. Try clicking the buttons.

0 current total Divided by 2

Class Lifecycle Events

  • Class_Initialize — called when Set obj = New ClassName executes
  • Class_Terminate — called when Set obj = Nothing executes (or object goes out of scope)
  • Properties declared with Public are readable/writable directly
  • Use Private fields + Property Let/Get/Set for controlled access
  • Methods can return values via Function or perform actions via Sub