0
votes

I'm making a COM dll in .NET for use in VB6, the dll works fine in VB6.

but I have a problem when I want to assign arrays.

here is the Person class in VB.NET, the Name property is an array of the class called Class2

Public Class Person

  Private _name() As Class2

  Public Property Name() As Class2()
     Get
       Return Me._name
     End Get
     Set
       Me._name = value
     End Set
  End Property

End Class

This is the Class2:

Public Class Class2

  Private m_id As String

  Public Property id() As String
    Get
      Return m_id
    End Get
    Set
      m_id = Value
    End Set
  End Property

End Class

this is the code I'm using in VB6:

Dim vArray(2) As MyLib.Class2
vArray(0).id = "Hello 1"
vArray(1).id = "Hello 2"
vArray(2).id = "Hello 3"

Dim i As New MyLib.Person
i.Name = vArray ' here throws an error
1
What error do you get? Can we have the exact error message please? - MarkJ

1 Answers

0
votes

Try

 Dim vArray(2) As Class2
        For index = 0 To vArray.Length - 1
            vArray(index) = New Class2
            vArray(index).id = "Hello " + index.ToString
        Next
        Dim i As New Person
        i.Name = vArray