Windows Scripting
  Home arrow Windows Scripting arrow Overloading Methods and More 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? 
WINDOWS SCRIPTING

Overloading Methods and More in VBScript
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2009-02-23

    Table of Contents:
  • Overloading Methods and More in VBScript
  • Information Overload
  • Using the Overloaded Constructor
  • Implementing Optional Parameters

  • 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


    Overloading Methods and More in VBScript


    (Page 1 of 4 )

    Many programming languages, such as Java or C, allow you to create overloaded methods and allow optional parameters for your methods. This ability has been removed from VB’s Scripting Edition; however, today I’m going to show you some coding techniques that will allow you to regain some of this functionality.

    To begin, let’s define what an overloaded method (constructor) really is.  Quite simply, overloading is the process of creating multiple instances of a method or function with the same name that accept different inputs and offer different outputs.  Programming languages that adhere to strict data types employ overloading to allow similar functions to work on different data types.

    public double square(double number)

    {

       return number * number;

    }

     

    public float square(float number)

    {

       return number * number;

    }

    In Java, for example, a constructor (basically, a function) is defined by its input and output types as well as its name.  So let’s assume you wanted to write a function that would output the square of a number.  It might accept a double type as an input, so naturally it would also output a double.  You might also want to create the same function again to work with floating point numbers.  This second instance would be the overloaded constructor.

    This, of course, isn’t possible in VBScript because function and subroutine names must be unique.  I suppose constructor overloading wasn’t deemed necessary since all variables in VBS are of type Variant anyway.

    More Windows Scripting Articles
    More By Nilpo


     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek