I'm trying to figure out if there is any way to create a Property for a
private array member. I have tried it like this:
' Property for the length of a side
Public Property SideLength(ByVal sideNumber As Integer) As Integer
Get
Return mSideLength(sideNumber)
End Get
Set(ByVal sideNum As Integer, ByVal Value As Integer)
mSideLength(sideNum) = Value
End Set
End Property
....and the declaration is like so:
' Array containing the length of each side
Private mSideLength As Integer()
' ...miscellaneous code...
mSideLength = New Integer(mSides - 1) _
{side1, side2, side3}
.... where msides is equal to the number of sides for the shape (in this
case, 3, as it is a triangle). The errors I am getting in declaring the
property are as follows:
C:\Documents and Settings\Eric\Desktop\Eric\School\Advanced VB
2\Shapes\ShapeLibrary\Triangle.vb(82): 'Set' method cannot have more than
one parameter.
C:\Documents and Settings\Eric\Desktop\Eric\School\Advanced VB
2\Shapes\ShapeLibrary\Triangle.vb(83): Name 'Value' is not declared.
I can tell you why I want to use this as a property, if you want, but
mainly, I want to know how (and if!) it is possible to Get/Set an array
member as a property. How would I code it? The book I have doesn't tell me
if it is or isn't possible.
-- Eric 2 1486
Eric A. Johnson wrote: I'm trying to figure out if there is any way to create a Property for a private array member. I have tried it like this:
' Property for the length of a side Public Property SideLength(ByVal sideNumber As Integer) As Integer
Get
Return mSideLength(sideNumber)
End Get
Set(ByVal sideNum As Integer, ByVal Value As Integer)
mSideLength(sideNum) = Value
End Set
End Property ...and the declaration is like so: ' Array containing the length of each side
Private mSideLength As Integer()
' ...miscellaneous code...
mSideLength = New Integer(mSides - 1) _
{side1, side2, side3} ... where msides is equal to the number of sides for the shape (in this case, 3, as it is a triangle). The errors I am getting in declaring the property are as follows: C:\Documents and Settings\Eric\Desktop\Eric\School\Advanced VB 2\Shapes\ShapeLibrary\Triangle.vb(82): 'Set' method cannot have more than one parameter. C:\Documents and Settings\Eric\Desktop\Eric\School\Advanced VB 2\Shapes\ShapeLibrary\Triangle.vb(83): Name 'Value' is not declared.
I can tell you why I want to use this as a property, if you want, but mainly, I want to know how (and if!) it is possible to Get/Set an array member as a property. How would I code it? The book I have doesn't tell me if it is or isn't possible.
-- Eric
You were close...
' Property for the length of a side
Public Property SideLength(ByVal sideNumber As Integer) As Integer
Get
Return mSideLength(sideNumber)
End Get
Set(ByVal Value As Integer)
mSideLength(sideNum) = Value
End Set
End Property
Ummm... duh... I guess I didn't notice the fact that the side number was
already included as part of the property declaration. Thanks for you help!
:-)
"Chris" <no@spam.com> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl... Eric A. Johnson wrote: I'm trying to figure out if there is any way to create a Property for a private array member. I have tried it like this:
' Property for the length of a side Public Property SideLength(ByVal sideNumber As Integer) As Integer
Get
Return mSideLength(sideNumber)
End Get
Set(ByVal sideNum As Integer, ByVal Value As Integer)
mSideLength(sideNum) = Value
End Set
End Property ...and the declaration is like so: ' Array containing the length of each side
Private mSideLength As Integer()
' ...miscellaneous code...
mSideLength = New Integer(mSides - 1) _
{side1, side2, side3} ... where msides is equal to the number of sides for the shape (in this case, 3, as it is a triangle). The errors I am getting in declaring the property are as follows: C:\Documents and Settings\Eric\Desktop\Eric\School\Advanced VB 2\Shapes\ShapeLibrary\Triangle.vb(82): 'Set' method cannot have more than one parameter. C:\Documents and Settings\Eric\Desktop\Eric\School\Advanced VB 2\Shapes\ShapeLibrary\Triangle.vb(83): Name 'Value' is not declared.
I can tell you why I want to use this as a property, if you want, but mainly, I want to know how (and if!) it is possible to Get/Set an array member as a property. How would I code it? The book I have doesn't tell me if it is or isn't possible.
-- Eric
You were close... ' Property for the length of a side Public Property SideLength(ByVal sideNumber As Integer) As Integer Get Return mSideLength(sideNumber) End Get Set(ByVal Value As Integer) mSideLength(sideNum) = Value End Set End Property This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Luke |
last post by:
Here is my emails to Danny Goodman (but probably he is very busy so he
didn't answered it).
First email(simple): Subject: JavaScript Arrays
"
We all know the array can act like HashMap, but is...
|
by: Sascha Herpers |
last post by:
Hi,
I wrote a c dll with a type library to use it in vb. No problem,
everything works fine.
Now I needed to pass an array of type double to the dll. I defined the
function in the type...
|
by: Gomaw Beoyr |
last post by:
Hello
Is there any explanation why Microsoft chose to implement
arrays as objects allocated on the heap instead of structs
allocated on the stack?
For "mathematical stuff", one normally...
|
by: Ben |
last post by:
Hi There
I am learning about reflection so apologies if this post is vague ...
I am doing some unit testing and have written a function that accepts
two objects and tests to see if their...
|
by: John Pass |
last post by:
Hi,
In the attached example, I do understand that the references are not changed
if an array is passed by Val. What I do not understand is the result of line
99 (If one can find this by line...
| |
by: Martin Jørgensen |
last post by:
Hi,
I'm relatively new with C-programming and even though I've read about
pointers and arrays many times, it's a topic that is a little confusing
to me - at least at this moment:
----
1)...
|
by: Doug_J_W |
last post by:
I have a Visual Basic (2005) project that contains around twenty
embedded text files as resources. The text files contain two columns
of real numbers that are separated by tab deliminator, and are...
|
by: Michael Howes |
last post by:
I have many double that each have a few thousand numbers in them.
I need to concatenate groups of these double arrays into a new set of
double.
I don't know the total # of points.
I thought it...
|
by: Gregosky |
last post by:
Hi guys,
I have written a library that manipulates data stored in double arrays. It took months to fine tune it and here it is, working fine. Everything was great until I started integrating my...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |