Consulting

Results 1 to 5 of 5

Thread: Retreiving the properties out of a class.

  1. #1

    Retreiving the properties out of a class.

    Hi there.. Desperate coder here.

    How in the heck do i just retrieve my variables that have been stored in a class? Why is this so frustrating to do?

    [vba]
    Dim dinger As Variant
    For c = 1 To 5
    For r = 1 To UBound(entryList)
    For Each dinger In entryList()
    -> ERROR ActiveCell.value = dinger.day
    [/vba] with error 91 object variable or with block variable not set.

    Here is the class code

    [vba]
    Option Explicit
    Private cDay As String ' duedate
    'gets and sets begin here
    'Day
    Public Property Get day() As String
    day = cDay
    End Property
    Public Property Let day(value As String)
    cDay = value
    End Property
    [/vba]

    the Entrylist variable is as such..
    Global entryList() As ClassEntry
    it has been re-dimmd over the course of the code to have roughly 3000 objects in it. My sets work fine...
    [vba]
    Set entryList(classCount) = New ClassEntry 'create a new class entry
    entryList(classCount).day = dates(r) 'set the date
    [/vba]
    where dates(r) is an array holding strings.

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Have you tried this line without parenthesis?
    [vba]For Each dinger In entryList[/vba]

  3. #3
    Got rid of the ()'s, same error.

  4. #4
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Perhaps:
    [vba]Dim dinger As Variant
    For c = 1 To 5
    For r = 1 To UBound(entryList)
    set dinger = entrylist(r)
    ActiveCell.value = dinger.day [/vba]
    Be as you wish to seem

  5. #5
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    I'd use:

    [vba]
    Sub tst()
    ReDim entrylist(20)

    For j = 0 To UBound(entrylist)
    Set entrylist(j) = New ClassEntry
    entrylist(j).day = Date + j
    Next

    For j = 0 To UBound(entrylist)
    x3 = entrylist(j).day
    Next
    End Sub

    [/vba]

Posting Permissions

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