Skip to Main ContentWindow-Eyes  Braille Sense  CCTV  Voice Sense  SyncBraille  Support  Training
GW Micro - Unleashing the power of your mind's eye.
 

Creating Custom Objects in VBScript - GWWiki

Jump to: navigation, search

Using an object to store and retrieve information can provide you with a comprehensive way to move data between various routines and different parts of your script. You can store data in an object's properties, and you can retrieve data using an object's methods, just like those objects available through the Window-Eyes COM interface.

VBscript provides a powerful method of creating custom objects by allowing you to instantiate a "copy" of a class, whose statements identify the properties and methods of the resulting object.

Let's jump right in with a simple example:

Class Dog
   Public Name
   Public Color
   Public Breed
End Class

This class sets up a structure to define a dog, and it includes three read/write properties: Name, Color, and Breed. To instantiate an instance of this class as an object, so that you can read and modify the parameters, use the New statement.

Set myDog = New Dog

The variable myDog is now an instantiated object based on the Dog class. You can now modify the object's properties, like this:

myDog.Name = "Rover"
myDog.Color = "Brown"
myDog.Breed = "Beagle"

You can then retrieve the property data the same way you would for any other object:

Dim myDogsName : myDogsName = myDog.Name
Dim myDogsColor : myDogsColor = myDog.Color
Dim myDogsBreed : myDogsBreed = myDog.Breed

TODO:

  • private variables
  • methods (Get/Set/Let)
  • events: Class_Inititate & Class_Terminate

This page was last modified on 1 May 2009, at 15:07.

This page has been accessed 6,943 times.


Text Size:
Decrease Text Size Increase Text Size

Personal tools

Powered by MediaWiki
Public Domain
© 2013 GW Micro, Inc. All Rights Reserved.
GW Micro, Inc.    725 Airport North Office Park    Fort Wayne, IN 46825
Ph: 260-489-3671 Fax: 260-489-2608    www.gwmicro.com    sales@gwmicro.com    support@gwmicro.com
Hours: M-F, 8a-5p, EDST