473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Creating ArrayList to store data

I have a project in which i need to add to existing code. My
predecessors, had all sorts of arraylist in which he would save his
information. How can i create an arraylist of (intnumber) so that i
can compare them against the original arraylist??

Please help, Thanks in advance

Sep 3 '07 #1
3 2951
On 3 Sep, 14:58, cmdolcet69 <colin_dolce...@hotmail.comwrote:
I have a project in which i need to add to existing code. My
predecessors, had all sorts of arraylist in which he would save his
information. How can i create an arraylist of (intnumber) so that i
can compare them against the original arraylist??

Please help, Thanks in advance
Probably something like this:

'at top of file
Imports System.Collections
Imports System.Collections.Generic

'under some function

dim myArrayList as New ArrayList(of IntNumber)

for each hisObject as IntNumber in hisArrayList

if (myArrayList.contains(hisObject)) then
'I already have his object in my list
else
'I don't already have his object in my array list
myArrayList.Add(hisObject)
end if
next

Sep 3 '07 #2
On Sep 3, 11:34 am, Phillip Taylor <Phillip.Ross.Tay...@gmail.com>
wrote:
On 3 Sep, 14:58, cmdolcet69 <colin_dolce...@hotmail.comwrote:
I have a project in which i need to add to existing code. My
predecessors, had all sorts of arraylist in which he would save his
information. How can i create an arraylist of (intnumber) so that i
can compare them against the original arraylist??
Please help, Thanks in advance

Probably something like this:

'at top of file
Imports System.Collections
Imports System.Collections.Generic

'under some function

dim myArrayList as New ArrayList(of IntNumber)

for each hisObject as IntNumber in hisArrayList

if (myArrayList.contains(hisObject)) then
'I already have his object in my list
else
'I don't already have his object in my array list
myArrayList.Add(hisObject)
end if
next
I added your following suggestion with a little modification:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim objects As Integer
Dim index As Integer
For objects = 0 To PassArrayList1(index)
objects += 1
Next

End Sub
However when i run it i get an error: An unhandled exception of type
'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

What does this mean and how can i fix this?

Sep 3 '07 #3
On Mon, 03 Sep 2007 15:51:40 -0700, cmdolcet69
<co************@hotmail.comwrote:
>On Sep 3, 11:34 am, Phillip Taylor <Phillip.Ross.Tay...@gmail.com>
wrote:
>On 3 Sep, 14:58, cmdolcet69 <colin_dolce...@hotmail.comwrote:
I have a project in which i need to add to existing code. My
predecessors, had all sorts of arraylist in which he would save his
information. How can i create an arraylist of (intnumber) so that i
can compare them against the original arraylist??
Please help, Thanks in advance

Probably something like this:

'at top of file
Imports System.Collections
Imports System.Collections.Generic

'under some function

dim myArrayList as New ArrayList(of IntNumber)

for each hisObject as IntNumber in hisArrayList

if (myArrayList.contains(hisObject)) then
'I already have his object in my list
else
'I don't already have his object in my array list
myArrayList.Add(hisObject)
end if
next

I added your following suggestion with a little modification:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim objects As Integer
Dim index As Integer
For objects = 0 To PassArrayList1(index)
objects += 1
Next

End Sub
However when i run it i get an error: An unhandled exception of type
'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

What does this mean and how can i fix this?
"with a little modification"? Your Sub bears no relation to the code
Philip posted.

You should be able to easily find bugs like this using the debugger.
Which line gets the error when you run with the debugger? No doubt it
is the For statement since you are indexing PassArrayList1 with a
variable you have not initialized.

Your For loop makes no sense. The For loop increments 'objects', but
then you increment it again yourself. You also never set the variable
'index'. The Sub doesn't return any value or affect any data outside
of itself, so even it it didn't trap it would have no effect.

I also don't see how this Sub has any relation to the original
question you asked.
Sep 4 '07 #4

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

Similar topics

2
by: clwoods | last post by:
I would like to ask is thier a better way to store data other than access tables, I would still like to keep access as the front end. My main quest I suppose is for more speed and maybe security....
1
by: Vaj | last post by:
Hi, I'm attaching a code here.this code works successfully, But my doubt is, Can an arraylist store this integer value "J" as wellas string value "S" ArrayList ArrMM=new ArrayList(); for(int...
0
by: stigbn | last post by:
When a DataSet is used as data source for a DataGrid one can get hiearachical datagrid by using relations among the DataTables of the DataSet. (By hierarchical datagrid, I mean columns that can be...
3
by: Forconi Boris via .NET 247 | last post by:
Hi, I'm working on a project in witch I have to list data(products that can be selected with a certain quantity) from anXML document, with key words entered by the user. A Table isdynamically created...
2
by: jmensch | last post by:
Hello. I'm a reasonably new ASP.NET programmer with no prior ASP or web development experience, but a lot of general programming experience. I'm using Visual Web Developer Beta Express 2005. ...
3
by: piotrek | last post by:
Hi I would like to ask you a question. Ian creating app. that download from server directory structure ( whole tree ) and those data are placed in proper places into my treeview control. I...
5
by: res7cxbi | last post by:
hi, im familiar with xml but wondering if it would be better to store data within attributes: <root> <data value="someData"/> </root> or within nodes:
3
nurulshidanoni
by: nurulshidanoni | last post by:
i hava a data student id examcode 1 002 006 001 2 123 589 How to store data when it have...
7
by: scoobydoo666 | last post by:
Hi How do I store data at a given memory location? For eg: I want to store 25 at location 1000. How do I do it? I tried using placement new(). But it is giving segmentation fault during runtime....
2
by: creative1 | last post by:
Is this possible to store data in an XML file using HTML form? I got it working other way. I can store data in an xml file and display it in html form. I need to do it other way. It is very urgent. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.