Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Passing an array in a user defined function | Excel Programming | |||
Passing a range to a user defined function | Excel Discussion (Misc queries) | |||
passing arrays to user defined functions | Excel Worksheet Functions | |||
Passing User Defined Type Array to Listbox | Excel Programming | |||
passing named range to a UDF user defined function | Excel Programming |