Code Examples
  Home arrow Code Examples arrow Page 3 - 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 - Adding properties to a class


    (Page 3 of 4 )

    You can set the permission level on properties and methods inside of a class.  For our purposes, we’ll be setting them as either Private or Public.  Private properties and methods are only available to code within the class itself.  Public properties and methods are available to outside scripts and applications, and are exposed through the class object.

    Properties and Methods are exposed through an object Interface.  With VBScript classes, these interfaces are created automatically for you.

    There are two types of properties in VBScript: Read/Write and Read-only.  A read/write property allows you to retrieve the property's current value or assign one.  A read-only property will only allow you to retrieve the current value.

    Properties are created using a Property structure.  There are three types of property structures: Property Get, Property Let, and Property Set.  Property Get is used to create a class property.  This is the structure that will Get or return the current property value.  Property Let is the counterpart; it accepts a parameter and allows the programmer to pass a value to be assigned to the property.  The Property Set structure is the same as Property Let, but it is used when a Property is being assigned an object value.

    All properties must have a Property Get block.  Properties that only have a Property Get block are treated as Read-only.  Properties that add either a Property Let or Property Set block are treated as Read/Write.

    A property is only required to have a Property Get structure.  Property Let and Property Set can be omitted if the property is to be treated as read-only.  You may also want to consider the fact that properties do not need to be made Public.  Private properties would only be available from inside the class itself.  I can’t think of a reason to do this myself, but I thought I’d at least mention it.

    Class CompressedFolder

       Private m_fileName

     

       Public Property Get FullName

           FullName = m_fileName  

       End Property

     

       Public Property Let FullName(strName)

           m_fileName = strName

       End Property

     

       Public Property Get Path

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

       End Property

    End Class

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