Error wrote:
Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types
This is supposed to be curable by declaring the class function as Friend, but that hasn't rescued me this time. I'm using
Andrew McMillan's PropertyBagClass, which I've gotten to accept UDTs before, but looking at my old code, I don't see any difference in my approach and yet I still get the errors.
Module1:
Code:
Public Type Appointment
RefNos() As String * 10
TimeSlot As Integer
AvailableTellers As Integer
End Type
Public Type AppointmentDay
Appointments() As Appointment
End Type
QueueItem.cls -
error is in this classCode:
Option Explicit
Public Name As String
Private QueueTellerCount As Integer 'set to 1 for regular queue, else set to n for bank style queue
Private SlotLength As Integer 'how long each slot is in minutes
Private SlotsPerDay As Integer 'how many slots per day
Private Days() As AppointmentDay 'array of slots for each day, containing ref no's.
Private DateStart As String 'format 2009/01/28
Public TimeStart As String 'format 01:46:11 PM
Private NextSlot As Integer 'for ref numbers without cellphone
Implements IPropertyBagClass
..........
Private Sub IPropertyBagClass_WriteProperties(PropBag As PropertyBagClass)
Dim i As Integer
PropBag.WriteProperty "Name", Name
PropBag.WriteProperty "QueueTellerCount", QueueTellerCount
PropBag.WriteProperty "SlotLength", SlotLength
PropBag.WriteProperty "SlotsPerDay", SlotsPerDay
PropBag.WriteProperty "UboundDays", UBound(Days)
For i = 0 To UBound(Days)
PropBag.WriteProperty "Days" & i, Days(i) 'ERROR OVER HERE
Next
PropBag.WriteProperty "DateStart", DateStart
PropBag.WriteProperty "TimeStart", TimeStart
PropBag.WriteProperty "NextSlot", NextSlot
End Sub
PropertyBagClass.cls
Code:
Public Sub WriteProperty(Name As String, Value As Variant, Optional DefaultValue As Variant) 'Changing this to Friend made no difference
Dim p As PropertyBagClass
Dim i As IPropertyBagClass
If TypeOf Value Is IPropertyBagClass Then
Set p = New PropertyBagClass
Set i = Value
i.WriteProperties p
Set i = Nothing
pb.WriteProperty Name, p.Contents
Set p = Nothing
Else
pb.WriteProperty Name, Value, DefaultValue
End If
End Sub
I've spent most of today trying to get this right, and I'm sure that it's something ridiculously simple that I'm missing. Please help me out.