Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default How to handle dynamic Array properties in a class module?

Hi all,

following Chip's suggestion to convert all my UDT to classes, I got
into a stumbling block: how to deal with a dynamic array property?
Suppose I have

Private pYValues() As Double

The Property Get should be trivial:

Public Property Get YValues() As Double()
YValues = pYValues
End Property

But how about the Property Let? I should handle the case of
unallocated and allocated array, but I cannot test allocation of a
dynamic array with Is Nothing. How can I get out of this? Thanks,

Best Regards

deltaquattro (Sergio Rossi)




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default How to handle dynamic Array properties in a class module?

You can handle it like so

========= Class Module
Private penalise() As Double

Public Property Get YValues() As Double()
YValues = pYValues
End Property

Public Property Let YValues(Values() As Double)
pYValues = Values
End Property

========= Standard Module
Dim cls As Class1
Dim ary() As Double

Set cls = New Class1

ReDim ary(1 To 3)
ary(1) = 1
ary(2) = 2
ary(3) = 3
cls.YValues = ary

ary = cls.YValues
MsgBox ary(2)

But as you can see, you effectively define and build the array in the
calling procedure.


--

HTH

Bob

"deltaquattro" wrote in message
...
Hi all,

following Chip's suggestion to convert all my UDT to classes, I got
into a stumbling block: how to deal with a dynamic array property?
Suppose I have

Private pYValues() As Double

The Property Get should be trivial:

Public Property Get YValues() As Double()
YValues = pYValues
End Property

But how about the Property Let? I should handle the case of
unallocated and allocated array, but I cannot test allocation of a
dynamic array with Is Nothing. How can I get out of this? Thanks,

Best Regards

deltaquattro (Sergio Rossi)






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default How to handle dynamic Array properties in a class module?

'K, thanks! It was simpler than I thought. I've coded that and, as
soon as I fix the other bugs in my code (see my new post :), I will
let you know how it work.

Best Regards

Sergio Rossi

On 15 Mar, 11:39, "Bob Phillips" wrote:
You can handle it like so

========= Class Module
Private penalise() As Double

Public Property Get YValues() As Double()
* * YValues = pYValues
End Property

Public Property Let YValues(Values() As Double)
* * pYValues = Values
End Property

========= Standard Module
Dim cls As Class1
Dim ary() As Double

* * Set cls = New Class1

* * ReDim ary(1 To 3)
* * ary(1) = 1
* * ary(2) = 2
* * ary(3) = 3
* * cls.YValues = ary

* * ary = cls.YValues
* * MsgBox ary(2)

But as you can see, you effectively define and build the array in the
calling procedure.

--

HTH

Bob

"deltaquattro" wrote in message

...

Hi all,


following Chip's suggestion to convert all my UDT to classes, I got
into a stumbling block: how to deal with a dynamic array property?
Suppose I have


Private pYValues() As Double


The Property Get should be trivial:


Public Property Get YValues() As Double()
* *YValues = pYValues
End Property


But how about the Property Let? I should handle the case of
unallocated and allocated array, but I cannot test allocation of a
dynamic array with Is Nothing. How can I get out of this? Thanks,


Best Regards


deltaquattro (Sergio Rossi)


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
Array Properties in a Class [email protected] Excel Programming 7 May 2nd 07 05:52 PM
Function in class module cannot be assigned an array? pinkfloydfan Excel Programming 3 February 28th 07 11:40 AM
How to modify fill handle properties? ashish Excel Discussion (Misc queries) 2 March 15th 06 06:05 AM
Problems Setting properties of class module Andibevan[_4_] Excel Programming 2 October 2nd 05 01:44 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 04:37 AM.

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"