Results 1 to 3 of 3

Thread: Object array issues

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    Atlanta, GA
    Posts
    75

    Object array issues

    I am looking for any suggestions to the following issue.

    I am working within an ActiveX DLL. I created a class called clsLinkedListNode. This class contains two private variables (Key and Value) and property procedures to access them.

    A second class exists named clsLinkedList. This class contains a private array of 100 objects of type clsLinkedListNode declared as follows:
    Private arrLinkedListNode(99) As New clsLinkedListNode
    The procedure used to add a Node is as follows:
    Public Sub subAdd(LobjLinkedListNode as clsLinkedListNode)
    [some code]
    arrLinkedListNode(LintCounter) = LobjLinkedListNode
    [some code]
    End Sub

    The problem occurs when I try to call the subAdd procedure from an outside program. Using the code above, I receive the following error:
    Error #438: Object doesn't support this property or method.
    Debugging takes me to the follwing line:
    arrLinkedListNode(LintCounter) = LobjLinkedListNode
    The error can be fixed by making the line read:
    Set arrLinkedListNode(LintCounter) = LobjLinkedListNode
    The problem here is that this statement sets all objects in the array equal to the object passed in.

    Is there an anwer to this issue? I know that arrays of objects has proven a sticky issue for a number of people. I am aware of the Collections object, but would prefer to do it with an array if possible. If not, I'll suck it up and do it via Collections.

    All help is appreciated greatly.

    Jay

  2. #2
    Lively Member
    Join Date
    Aug 1999
    Location
    Blackpool, England
    Posts
    87
    I would use the dictionary objects contained within the filesystemobjewct. They are alot more powerfull than collections

  3. #3
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482
    This is a blind shot from the hip, but could be worth a try... (i.e., I've not tested/validated it). But try something like this:
    Code:
    ' First... fix this!
    ' Private arrLinkedListNode(99) As New clsLinkedListNode 
    '                                  ^ very bad kitty idea...
    Private arrLinkedListNode(99) As clsLinkedListNode 
    
    Private Sub Class_Initialize()
      Set arrLinkedListNode(99) = New clsLinkedListNode 
    End Sub
    
    Public Sub subAdd(LobjLinkedListNode as clsLinkedListNode) 
    [some code] 
    Dim Upper As Integer
      On Error Resume Next
      Upper = UBound(arrLinkedListNode)
      If Err.Number Then
        '  since adding implies removing...
        Upper = 0
      Else
        Upper = UBound(arrLinkedListNode) + 1
      End If
      On Error GoTo 0
      ReDim Preserve arrLinkedListNode(Upper)
      With arrLinkedListNode(Upper)
        .Key = LobjLinkedListNode.Key
        .Value = LobjLinkedListNode.Value
      End With
    [some code] 
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width