Sébastien’s Coding Journey

March 31, 2010

VBScript’s default keyword

Filed under: VBScript — Tags: — Sébastien Ayotte @ 6:50 am

While I’m digging more and more into VBScript, I learned that you can use the default keyword to mark a default method in a class.

First, we define a class MyClass where is default sub is myDefaultSub.

public class MyClass

  public default sub myDefaultSub(p_value)
    response.write p_value
  end sub

  public sub notADefaultSub(p_value)
    response.write p_value
  end sub

end class

Second, we instantiate MyClass and we use it.

dim objMyClass : set objMyClass = new MyClass

objMyClass("This is calling the default sub.")

objMyClass.notADefaultSub("This is not the default sub.")

Cheers :-)



  1. […] 参考链接:VBScript’s default keyword […]

    Pingback by VBS类构造函数与Default关键字 | Demon's Blog — October 20, 2011 @ 6:44 am

  2. This is awesome; I had no idea you can do such thing in VBScript

    Comment by Maciej Zaleski — May 28, 2014 @ 3:21 am

  3. […] 参考链接:VBScript's default keyword原文:http://demon.tw/programming/vbs-default-keyword.html […]

    Pingback by VBS类构造函数与Default关键字使用介绍 引力一族 — July 25, 2017 @ 1:50 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: