Code Examples
  Home arrow Code Examples arrow Page 4 - 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 - More on adding properties


    (Page 4 of 4 )

    I’ve begun constructing my class by adding some properties.  Notice how the Property structures look like functions that are executed when a property is retrieved or assigned.  Immediately inside of my class I’ve created a few private variables.  These are global variables that I’ll be using throughout my class to track the value of the properties.

    In this example, I’ve added two properties.  The FullName property has both Get and a Let, so it is a Read/Write property.  The Path property only has a Get structure, so it is a Read-only property.  These properties could now be used in my script.

    Set objZipFolder = New CompressedFolder

    WScript.Echo objZipFolder.FullName

    objZipFolder.FullName = "My new FullName value"

    WScript.Echo objZipFolder.Path

    Here is the complete property listing for the CompressedFolder class.

    Class CompressedFolder

       Private m_fileName

     

       Public Property Get FullName

           FullName = m_fileName  

       End Property

     

       Private Property Let FullName(strName)

           m_fileName = strName

       End Property

     

       Public Property Get Filename

           Filename = Right(FullName, Len(FullName) - InStrRev(FullName, ""))

       End Property

     

       Public Property Get Path

           Path = Left(FullName, InStrRev(FullName, ""))

       End Property

     

       Public Property Get Count

           Count = GetItemCount(FullName)

       End Property

    End Class

    Having a few properties doesn’t do much for this class.  We need a way to create the compressed folder and to manipulate it.  For that we need to add some methods.  These are the functions and subroutines that perform the magic when the class is called.  For that, you’ll also need to wait for part two of this series!  Until next time, keep coding!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    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 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek