Solved

Constructors in VB classes

Posted on 2002-07-03
1
187 Views
Last Modified: 2010-05-02
I'm writing a VB class wrapping an XML document.  I would like to be able to create the class from a node in the constructor as follows:

    Dim node As IXMLDomNode
    Set node = GetNodeFromSomeWhere

    Dim myClass As New clsFoo(node)

Is this valid vb syntax, or do I have to do 2 phase construction as follows:

    Dim node As IXMLDomNode
    Set node = GetNodeFromSomeWhere

    Dim myClass As New clsFoo
    myClass.SetNode node
0
Comment
Question by:derekl
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 7127575
>>Dim myClass As New clsFoo(node)

This syntax is available in VB.Net (and C#).
For VB6, you have to do in 2 phases...

CHeers

0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question