Classic ASP class constructors with parameters

By · June 8, 2016 · 0 comments

Although probably no one cares about Classic ASP, except those who still need to support it, I was refreshing my memory today on how to use classes in Classic ASP and found a couple of options for simulating constructors with parameters.

We start with a simple class and add a default function that returns the current instance:

Class MyClass
Private m_myvalue

Public Default Function Init(myvalue)
m_myvalue= myvalue

Set Init = Me
End Function

Public Property Get MyValue
MyValue = m_myvalue
End Property
End Class

Then we can create an instance of our class with a faux constructor, like this...

Set myobject = (New MyClass)(123)

...or, if you prefer, this...

Set myobject = New MyClass.Init(123)

Sources: and
Classic ASP

Get the latest posts delivered to your inbox.


There are no comments yet. Be the first to leave a comment!

Leave a Comment

All comments are moderated and rel="nofollow" is in use. Avatars are sourced from – a globally recognised avatar.

Type the numbers from the picture above

About me
John Avis ...mostly about web development and programming, with a little bit of anything else related to the Internet, computers and technology.

profile for John at Stack Overflow, Q&A for professional and enthusiast programmers

Get the latest posts delivered to your inbox. *