473,498 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ArrayLIst as a component of a class

I have a class named INDICE that have two properties NAME and COMP
Name is declared as string
COMP is declared as an ArrayList

I have the following code

Dim Ind as New Indice
Ind.Name="Something"

Ind.Comp.Add("XXX")

THis last line give me an error "The reference to an object is not
referenced to its intance"

Thanks for your help

Bernard
Nov 21 '05 #1
2 948
Hi there... Where are you instantiating the arraylist object? This error
happens because its value is nothing (null). You can instantiate it in the
constructor or just where it is declared... For example

Class INDICE
private m_name As String, _
m_comp As ArrayList

Public Sub New()
m_comp = New ArrayList
End Sub

' Properties come here... they expose my class' private fields
End Class

Or like this..

Class INDICE
private m_name As String, _
m_comp As New ArrayList

Public Sub New()
End Sub

' Properties come here... they expose my class' private fields
End Class

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://www.consein.com


"Bernard Bourée" <be*****@bouree.net> escribió en el mensaje
news:%2***************@TK2MSFTNGP12.phx.gbl...
I have a class named INDICE that have two properties NAME and COMP
Name is declared as string
COMP is declared as an ArrayList

I have the following code

Dim Ind as New Indice
Ind.Name="Something"

Ind.Comp.Add("XXX")

THis last line give me an error "The reference to an object is not
referenced to its intance"

Thanks for your help

Bernard

Nov 21 '05 #2
Thanks Angel

Bernard

Angel J. Hernández M. a écrit :
Hi there... Where are you instantiating the arraylist object? This error
happens because its value is nothing (null). You can instantiate it in the
constructor or just where it is declared... For example

Class INDICE
private m_name As String, _
m_comp As ArrayList

Public Sub New()
m_comp = New ArrayList
End Sub

' Properties come here... they expose my class' private fields
End Class

Or like this..

Class INDICE
private m_name As String, _
m_comp As New ArrayList

Public Sub New()
End Sub

' Properties come here... they expose my class' private fields
End Class

Regards,

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1669
by: raymi | last post by:
Hi, I have a custom class that gets its properties dynamically from a database at runtime. Therefore I implemented the ICustomTypeDescriptor in this class and created a a custom...
4
2452
by: tma | last post by:
I'm trying to save code to a session object like the following: dim oAppList as arraylist dim oApp as someclass Code to manipulate oApp... .... .... oApplist.Add(oApp)...
2
1034
by: Jason Reis | last post by:
I need to keep track of up to 100 values. When the list reaches 100, I'd like the first to be removed and the new item added to the end. My first thought was the Stack class, but I need to be...
4
1062
by: Don | last post by:
Can please someone help before I go bald from pulling my hair out. I created a usercontrol that contains a combo box and an array list. Each item in the combobox has 1 additional parameter that...
3
1967
by: RBCC | last post by:
I have a form with a listbox and two textboxes. In the listbox I have the make and models of automobiles. and as the user clicks on the make of the car in the listbox I would like to output the make...
2
1371
by: RBCC | last post by:
I have a form with a 2 textboxes and a listbox, The data is read in by a file called "memberphones" The listnbox lists names in this way (lastname,first name) sorted by the last name. the...
18
4705
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
16
6395
by: RCS | last post by:
So I have an ArrayList that gets populated with objects like: myAL.Add(new CustomObject(parm1,parm2)); I'm consuming this ArrayList from an ObjectDataSource and would like to have this support...
2
2470
by: Jayme Pechan | last post by:
I migrated a formerly C++ COM component to C# and I have been able to duplicate all the old behavior except for one. I have an enumeration property that returns a list of com objects. Using the...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
tracyyun
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...
0
5462
agi2029
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,...
1
4910
isladogs
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...
0
4590
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...
0
1419
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 ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.