Error: Object variable not set
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Error: Object variable not set

  1. #1
    Join Date
    Dec 2012
    Posts
    1

    Error: Object variable not set

    In this code I have an issue passing an array between classes. So I have created a class called "Containers" with a class within "Containers" called "POs". To keep the code short, I'll just paste the parts that are affected:

    Within the Container class:

    Private pPOs() As PO

    Public Property Get POs() As PO
    Set POs = New POs
    For C = 1 To UBound(POs)
    POs(C) = pPOs(C)
    Next C
    End Property
    Public Property Let POVar(Value As PO)
    Set POVar = New PO
    If POs(1).POName <> "" Then
    ReDim Preserve pPOs(1 To UBound(pPOs) + 1)
    End If
    pPOs(UBound(pPOs)) = Value
    End Property
    --------------------------------------------------------------

    Within the main code:

    Range("A2").Select
    For C = 1 To UBound(Tracker)
    POs(C).POName = ActiveCell.Value <--------- Error happens here.
    POs(C).Carrier = ActiveCell.Offset(0, 57).Value
    POs(C).ProjInDCDate = ActiveCell.Offset(0, 52).Value
    POs(C).Entity = ActiveCell.Offset(0, 8).Value
    POs(C).Location = ActiveCell.Offset(0, 3).Value
    POs(C).CaseCount = ActiveCell.Offset(0, 19).Value
    POs(C).POWeight = ActiveCell.Offset(0, 67).Value
    POs(C).POTrailer = ActiveCell.Offset(0, 62).Value
    If ActiveCell.Offset(0, 62).Value <> " " Then
    Containers = CheckContainerArray(Containers)
    End If
    Next C

    ---------------------------------------------------------------------

    I believe the issue lies within the "setters and getters" portion of the code so the array isn't being populated correctly.

    Any help or advice would be greatly apprecated.

    FYI - I'm fairly new to coding... The one of my first projects and I'm self learning.

    Thanks a million!!

    -Likuid

  2. #2
    Join Date
    Dec 2001
    Posts
    6,330

    Re: Error: Object variable not set

    Have you created an instance of the class within the main code?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center