Code Examples
  Home arrow Code Examples arrow Custom Class Objects in VBScript
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Custom Class Objects in VBScript
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2009-03-16

    Table of Contents:
  • Custom Class Objects in VBScript
  • Creating Code Classes in VBScript
  • Adding properties to a class
  • More on adding properties

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Custom Class Objects in VBScript


    (Page 1 of 4 )

    A code class in VBScript (and most other programming languages) is a structure that houses a set of related properties, methods, and events that can be reused throughout your code. In object-oriented languages, this code class is instantiated as an object reference. In today’s article, I’m going to show you how you can create your own custom VBScript object classes for use in WSH, ASP, or HTML applications.

    In VBScript we’re used to using several different objects.  The WScript object, the Server object, and the FileSystemObject are just a few that you probably use every day.  These objects actually point to code classes.  In this case, we’re referring to classes that are housed inside of a dll file somewhere on the system and made available through the Component Object Model (COM).

    The terms class, object, and component are sometimes, albeit incorrectly, used interchangeably.  An object is a reference to either a class or a component.  A class is a local structure that only exists at the time of execution.  It is only available to those scripts and programs that can access it directly.  It needs to be present in the current script.

    A component, on the other hand, is a code package.  This package is stored globally on the system and can be reused by any script or program with permission to access it.  These components may contain one or more code classes that become available to the local script when the component is instantiated.  Most often, these components are pre-registered with the Component Object Model so that they can be referenced globally via their ProgID.  In this way, the system itself manages the connection to the component and the programmer does not need to know where the component file is located on the system.

    In VBScript, components are instantiated using the CreateObject or GetObject methods.  Classes, on the other hand, are instantiated using the New keyword.  In each of these cases, an object reference is returned that can be assigned to a variable by using the Set keyword.  You should be used to seeing commands like the following.

    Set objFso = CreateObject("Scripting.FileSystemObject")

    Set objRe = New RegExp

    The first is a typical use of the CreateObject method to connect to a COM component.  The latter demonstrates the use of the New keyword for instantiating a local class named RegExp.  RegExp is one of the few local classes provided by the scripting engine itself.

    To date you have probably only used the default classes and components that ship with the Windows Scripting Host or with COM, but there are a plethora of others out there that you can install and use.  For now though, my next few articles will concentrate on creating your own classes and components.

    More Code Examples Articles
    More By Nilpo


     

    CODE EXAMPLES ARTICLES

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT