Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default User defined type problem

I have a public User defined type that i would like to use throughout my
code. I have put it in a module.


However, when I have a class that contains a scripting.dictionary of
these types return the Type in a function, I get the following error:

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


Then, when I try to put the public type definition in the class module,
it complains:

"Cannot define a Public user-defined type within an object module"


What is going on? How can I get around this? It seems as though the
errors are saying two contradictory things. Any help would be most
appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default User defined type problem

I'm afraid I didn't say exactly what i meant. To clear up all
confusion, the code is below.

The problem occurs when I want to store many of these Types in a
Collection or Dictionary. The compiler complains about various things,
depending on where and what scope the Type is defined with.

Basically, I want to store a LOT of MyType records in a dictionary so
that I can immediately summon on by Key. If I cannot do this directly,
I guess an alternative would be to store them in an array, and store the
keys and array indices in a dictionary. However, this is a little less
intuitive and natural, and a lot more annoying. Any help would be
appreciated.


################################################
Module code
################################################


Type MyType
Item1 As String * 6
Item2 As Double
End Type

################################################
Class Module code
################################################





Private colItems As Collection


Private Sub Class_Initialize()
Set colItems = New Collection
End Sub

Public Sub Add(ByRef WhichItem As MyType)
colItems.Add WhichItem
End Sub

Public Function Item(ByVal Index As Long) As MyType
Item = colItems.Item(Index)
End Function



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Message "user defined type not defined" LEELK01 Excel Discussion (Misc queries) 2 August 14th 09 07:31 AM
"User-defined type not defined" message in Excel RW1946 Excel Discussion (Misc queries) 0 August 31st 05 12:14 PM
User Defined type not defined Karpagam Excel Programming 1 May 16th 04 05:41 PM
User defined data type augustus108 Excel Programming 1 April 10th 04 05:11 PM
Word.Document - user defined type not defined jowatkins[_7_] Excel Programming 0 January 20th 04 08:46 AM


All times are GMT +1. The time now is 02:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"