GPWiki.org
GPWiki.org
It is currently Tue Jun 18, 2013 9:09 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Feb 12, 2009 2:11 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3746
Location: South Africa
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 class
Code:
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.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 2:40 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2217
Location: England
I've never really played with class and type, so I don't know, but...

can we use 'Name' as a variable? I'm sure I've run into variable naming clashes reminiscent of this before. Try a different word. :)

Also, what happens if you change the declarations in QueueItem.cls from private to public?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 2:59 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3746
Location: South Africa
Quote:
Also, what happens if you change the declarations in QueueItem.cls from private to public?


I get the error: Constants, fixed-length strings, arrays, user-defined types, and Declare statements not allowed as Public members of an object module

With protected name clashes, VB has always directly complained about it. I don't think Name is protected though.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group