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.