Classic ASP class constructors with parameters
by johna | June 8, 2016 | Classic ASP Web Development
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:
Then we can create an instance of our class with a faux constructor, like this...
...or, if you prefer, this...
Sources: www.visualbasicscript.com/Initializing-a-Class-with-parameters-m76239.aspx and brendangadd.blogspot.com.au/2011/06/constructors-in-asp-classic.html.
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.
Related Posts
Converting dBase IV programs to run in the browser
by johna | September 13, 2024
Some pointless entertainment trying to get some old dBase programs running in the browser.
How to set up a debugging using the Turnkey Linux LAMP stack and VS Code
by johna | December 19, 2023
The second part in my guide to setting up a website and database using the Turnkey Linux LAMP stack.
How to set up a website and database using the Turnkey Linux LAMP stack
by johna | November 18, 2023
If you need to host your own website for the purposes of web development, Turnkey Linux LAMP Stack is an easy to install all-in-one solution that you can set up on a spare computer or a VM (Virtual Machine).
Comments
There are no comments yet. Be the first to leave a comment!