Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Passing collections to an object

Hi,

I'm having some difficulties with some classes I set up. I'd like to have
each instance of my class "own" a dictionary object. I can set it up in the
class and work with it. My problem is in communicating it outside of the
class, or alternatively passing a dictionary object to my class either
through a method or a procedure.

I'm getting the feeling that you just can't do this. Is that true? Is
there something I'm missing? Along with this I'd like to be able to pass an
array to or from an object. Can this be done?

I'd appreciate any advice, or even some fairly definitive bad news.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Passing collections to an object

See Tushar Mehta's post he

http://groups.google.com/group/micro...b70a9ca1a2533f

Hth,
Merjet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Passing collections to an object

P.S. If it's not clear from Tushar Mehta's post, yes, you can pass an
array to and from a Class. "Dim" a Class member variable as type
Variant and pass an array to it via a Property Let procedure.

Hth,
Merjet


  #4   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Passing collections to an object

I'm surprised -- I had thought I couldn't do it. I'll read through the post
tomorrow (actually later today) when I'm awake (it's 1:00 AM here). I think
this will save me a lot of effort.



"merjet" wrote:

See Tushar Mehta's post he

http://groups.google.com/group/micro...b70a9ca1a2533f

Hth,
Merjet



  #5   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Passing collections to an object

I did have a little trouble following it, but got what I needed to work. For
what it's worth, I pasted my test code below, in case it's of any use.
Actually I think my only problem was not using "Set" where I needed it.

Thanks again for letting me know it was doable.

'---This is a regular module---
Sub main()
Dim x As New Class1
Dim y As New Class2
Dim z
Set z = CreateObject("scripting.dictionary")
x.Name = "Art"
x.Age = 54
y.C1 = x
y.add = x
Set z = y.Coll
End Sub
'---End of module---


'---This is class 1---
Dim mName As String
Dim mAge As Integer

Property Let Name(ByVal Value As String)
mName = Value
End Property
Property Get Name() As String
Name = mName
End Property

Property Let Age(ByVal Value As Integer)
mAge = Value
End Property
Property Get Age() As Integer
Age = mAge
End Property
'---End of class 1---


'---This is class 2---
Dim mC1 As Class1
Dim z

Property Let C1(ByRef Value As Class1)
Set mC1 = Value
End Property
Property Get C1() As Class1
Set C1 = mC1
End Property

Property Let add(ByRef Value As Class1)
z.add 1, Value
End Property

Property Get Coll()
Set Coll = z
End Property

Private Sub Class_Initialize()
Set z = CreateObject("Scripting.Dictionary")
End Sub
'---End of Class 2---





"merjet" wrote:

P.S. If it's not clear from Tushar Mehta's post, yes, you can pass an
array to and from a Class. "Dim" a Class member variable as type
Variant and pass an array to it via a Property Let procedure.

Hth,
Merjet



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
Passing a variant object to a C++ dll Martin[_29_] Excel Programming 1 November 24th 06 01:44 PM
Passing a .NET DataSet object to Excel to be used with VBA Teddy Sohnrey Excel Programming 0 August 17th 06 12:07 PM
Passing a Label object to another procedure derobin Excel Programming 1 August 16th 06 10:43 AM
passing an object mark Excel Programming 2 May 22nd 06 04:37 PM


All times are GMT +1. The time now is 07:19 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"