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: www.visualbasicscript.com/Initializing-a-Class-with-parameters-m76239.aspx and brendangadd.blogspot.com.au/2011/06/constructors-in-asp-classic.html.
Rate this post:
Comments
There are no comments yet. Be the first to leave a comment!