PDA

View Full Version : Retreiving the properties out of a class.



magelan
09-20-2012, 02:42 PM
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?


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
with error 91 object variable or with block variable not set.

Here is the class code


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


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...

Set entryList(classCount) = New ClassEntry 'create a new class entry
entryList(classCount).day = dates(r) 'set the date

where dates(r) is an array holding strings.

mikerickson
09-20-2012, 05:37 PM
Have you tried this line without parenthesis?
For Each dinger In entryList

magelan
09-20-2012, 08:05 PM
Got rid of the ()'s, same error.

Aflatoon
09-21-2012, 02:08 AM
Perhaps:
Dim dinger As Variant
For c = 1 To 5
For r = 1 To UBound(entryList)
set dinger = entrylist(r)
ActiveCell.value = dinger.day

snb
09-21-2012, 02:37 AM
I'd use:


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