Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 227103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:34:14+00:00 2026-05-11T19:34:14+00:00

I found a way to extend classes in VBScript, but are there any ways

  • 0

I found a way to extend classes in VBScript, but are there any ways to pass in parameters or overload the constructor? I am currently using an Init function to initialize the properties, but would like to be able to do this when I create the object.
This is my sample class:

Class Test
    Private strText

    Public Property Get Text
        Text = strText
    End Property

    Public Property Let Text(strIn)
        strText = strIn
    End Property

    Private Sub Class_Initialize()  
        Init
    End Sub  

    Private Sub Class_Terminate()   

    End Sub 

    Private Function Init
        strText = "Start Text"
    End Function    
End Class

And I create it

Set objTest = New Test

But would like to do something like this

Set objTest = New Test(strInitText)

Is this possible, or does the object have to be created and initialized in two setps?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:34:14+00:00Added an answer on May 11, 2026 at 7:34 pm

    Just to alter slightly on svinto’s method…

    Class Test
      Private m_s
      Public Default Function Init(s)
        m_s = s
        Set Init = Me
      End Function
      Public Function Hello()
        Hello = m_s
      End Function
    End Class
    
    Dim o : Set o = (New Test)("hello world")
    

    Is how I do it. Sadly no overloading though.

    [edit]
    Though if you really wanted to you could do something like this…

    Class Test
        Private m_s
        Private m_i
    
        Public Default Function Init(parameters)
             Select Case UBound(parameters)
                 Case 0
                    Set Init = InitOneParam(parameters(0))
                 Case 1
                    Set Init = InitTwoParam(parameters(0), parameters(1))
                 Else Case
                    Set Init = Me
             End Select
        End Function
    
        Private Function InitOneParam(parameter1)
            If TypeName(parameter1) = "String" Then
                m_s = parameter1
            Else
                m_i = parameter1
            End If
            Set InitOneParam = Me
        End Function
    
        Private Function InitTwoParam(parameter1, parameter2)
            m_s = parameter1
            m_i = parameter2
            Set InitTwoParam = Me
        End Function
    End Class
    

    Which gives the constructors…

    Test()
    Test(string)
    Test(integer)
    Test(string, integer)
    

    which you can call as:

    Dim o : Set o = (New Test)(Array())
    Dim o : Set o = (New Test)(Array("Hello World"))
    Dim o : Set o = (New Test)(Array(1024))
    Dim o : Set o = (New Test)(Array("Hello World", 1024))
    

    Bit of a pain though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 169k
  • Answers 169k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's hard to say which one is "better".... First -… May 12, 2026 at 1:53 pm
  • Editorial Team
    Editorial Team added an answer Structured English is a 'standardised' pseudo-code language. May 12, 2026 at 1:53 pm
  • Editorial Team
    Editorial Team added an answer You need to expand function xxx to support IE, which… May 12, 2026 at 1:53 pm

Related Questions

I'm looking for an easy way to extend existing JPA mapping. The idea is
We recently built a web app using Prototype, making a fair amount of use
For my university class we are developing a multi-threaded Blackberry application which allows us
I'm developping a small UML Class editor in Java, mainly a personal project, it

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.