Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Passing Arrays in User Defined Objects

I have a Private Field in a Class Module that is a string dynamic array. (It
contains a list of part numbers containing letters.)

Is it possible to either -

1) Allow a procedure outside the Class Module to read the entire array
through a Get Property procedure.

2) Allow a procedure outside the Class Module to set the entire array using
a Let/Set Property procedure.

I know how to pass one value at a time through Get and Let, but is it
possible to pass the whole array at once through a Property procedure? I
would prefer not to expose the array (I would like to keep it Private), but I
suppose that is something I could fall back on.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Passing Arrays in User Defined Objects

Think of the array as a data like a string or integer. The following
works with VB6 -- XL2000 or later (tested only on 2003). For VB5 --
XL97 -- you will have to use a variant because the language doesn't
support an array as a procedure return type.

Option Explicit
Option Base 0

Sub testIt()
Dim x As New Class1, y() As String, z() As String
ReDim y(2)
y(0) = "a": y(1) = "bb": y(2) = "ccc"
x.MyArr = y
z = x.MyArr
MsgBox LBound(x.MyArr) & "," & UBound(x.MyArr) _
& "," & LBound(z) & "," & UBound(z)
MsgBox z(UBound(z))
End Sub

and the class module:
Option Explicit

Private sMyArr() As String
Property Get MyArr() As String()
MyArr = sMyArr
End Property
Property Let MyArr(uMyArr() As String)
sMyArr = uMyArr
End Property

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I have a Private Field in a Class Module that is a string dynamic array. (It
contains a list of part numbers containing letters.)

Is it possible to either -

1) Allow a procedure outside the Class Module to read the entire array
through a Get Property procedure.

2) Allow a procedure outside the Class Module to set the entire array using
a Let/Set Property procedure.

I know how to pass one value at a time through Get and Let, but is it
possible to pass the whole array at once through a Property procedure? I
would prefer not to expose the array (I would like to keep it Private), but I
suppose that is something I could fall back on.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Passing Arrays in User Defined Objects

This should help me very much!

Thank you!

"Tushar Mehta" wrote:

Think of the array as a data like a string or integer. The following
works with VB6 -- XL2000 or later (tested only on 2003). For VB5 --
XL97 -- you will have to use a variant because the language doesn't
support an array as a procedure return type.

Option Explicit
Option Base 0

Sub testIt()
Dim x As New Class1, y() As String, z() As String
ReDim y(2)
y(0) = "a": y(1) = "bb": y(2) = "ccc"
x.MyArr = y
z = x.MyArr
MsgBox LBound(x.MyArr) & "," & UBound(x.MyArr) _
& "," & LBound(z) & "," & UBound(z)
MsgBox z(UBound(z))
End Sub

and the class module:
Option Explicit

Private sMyArr() As String
Property Get MyArr() As String()
MyArr = sMyArr
End Property
Property Let MyArr(uMyArr() As String)
sMyArr = uMyArr
End Property

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I have a Private Field in a Class Module that is a string dynamic array. (It
contains a list of part numbers containing letters.)

Is it possible to either -

1) Allow a procedure outside the Class Module to read the entire array
through a Get Property procedure.

2) Allow a procedure outside the Class Module to set the entire array using
a Let/Set Property procedure.

I know how to pass one value at a time through Get and Let, but is it
possible to pass the whole array at once through a Property procedure? I
would prefer not to expose the array (I would like to keep it Private), but I
suppose that is something I could fall back on.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Passing Arrays in User Defined Objects

In article ,
says...
This should help me very much!

Thank you!

{snip}

You are welcome.
--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
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 an array in a user defined function Peter M Excel Programming 5 June 27th 08 10:45 PM
Passing a range to a user defined function Gary Nelson Excel Discussion (Misc queries) 1 July 19th 07 04:22 PM
passing arrays to user defined functions ramki Excel Worksheet Functions 2 February 15th 06 08:34 AM
Passing User Defined Type Array to Listbox PC[_4_] Excel Programming 2 June 1st 05 02:44 AM
passing named range to a UDF user defined function Brian Murphy Excel Programming 3 June 13th 04 08:38 PM


All times are GMT +1. The time now is 12:43 PM.

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

About Us

"It's about Microsoft Excel"