-
Apr 17th, 2012, 06:05 AM
#1
Thread Starter
New Member
declaring a class property as an array
Hello people. Please bear with me as I am not a programmer but a mechanical engineer that does programming!!! I am using VBA with excel. I am creating an object oriented gas dynamic simulation program where i have created a class for each of the components that will be used in the system being simulated. For example there will be many pipes in the system being simulated so I have created a pipe class, which I can then create many instances of. I would like to store data for the pipe (for example) in an array. However I cannot declare a property as an array. I have got round this by declaring the array I wantas a variant, and then have another routine within the class which says something like. In the example below pipe_array is a variant, pipe_array2 is the array I want.
Sub add_pipe_data(pipe_array2)
pipe_array = pipe_array2
End Sub
Is there a better way of dealing with this situation? I imagine it must be one that crops up a lot! Thaks
-
Apr 17th, 2012, 06:09 AM
#2
Thread Starter
New Member
Re: declaring a class property as an array
Sorry I didn't proof read that at all, just to clarify, the little bit of code makes the pipe_array variant into an array of the correct number of elements and including any data in the pipe_array2
-
Apr 17th, 2012, 06:41 AM
#3
Re: declaring a class property as an array
Yes it's possible...
it's been a while but I think this is right:
Code:
Public property Let MyProperty(value as String()) ' Property that is an array of string
mMyStrings = value
End Property
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|