|
-
Aug 14th, 2009, 08:13 PM
#1
Thread Starter
Addicted Member
passing arrayllist value into another class
anybody how to pass arraylist value in to another class?
pls help..
tnx
-
Aug 14th, 2009, 11:11 PM
#2
Re: passing arrayllist value into another class
You'll have to be way more specific then that. Are you talking about the constructor or a method perhaps? With that said, it's not any different from passing any other argument type.
-
Aug 15th, 2009, 01:58 PM
#3
Re: passing arrayllist value into another class
Also, there is usually no good reason to be using ArrayList - you should use a strongly typed List(Of T). So for example if your ArrayList contains just string values then you would have:
vb Code:
Dim MyList As New List(Of String)
-
Aug 16th, 2009, 06:49 PM
#4
Thread Starter
Addicted Member
Re: passing arrayllist value into another class
yes,i only pass string value and i stored it into an arraylist..and i wanted to access this arraylist value into another form..is arraylist the right to use?
tnx
-
Aug 16th, 2009, 06:51 PM
#5
Thread Starter
Addicted Member
Re: passing arrayllist value into another class
by the way i am using VB2003..i try list but i think this not supported in this version..
-
Aug 16th, 2009, 07:22 PM
#6
Re: passing arrayllist value into another class
Ah, no its not supported in that version unfortunately. If you mark your thread as VS 2003 then people will know not to suggest things that are not available to you.
Anyway, you need to explain what exactly you are trying to do but speaking in general, to pass a value in an ArrayList to anything (a class, a method, whatever) you just do this:
That's assuming you want the first item in the list, if you wanted the second item it would be:
If you wanted to do something for every single item in the list, you could either pass the actual ArrayList itself to your class/method and then that would do a loop or you could do a loop and call the method, like so:
vb Code:
For Each str As String In MyArrayList
MyMethod(str) 'calling a method and passing the current string in the loop to it
End For
Thats all a bit general but its hard to give you anything more specific when you havent given us any information..
-
Aug 17th, 2009, 12:28 AM
#7
Thread Starter
Addicted Member
Re: passing arrayllist value into another class
thank you very much chris128
that would be a big help! it solved my problem..
tnx
glen
-
Aug 17th, 2009, 01:34 AM
#8
Re: passing arrayllist value into another class
Give class2 a property of type List() and then assign your array list to that property.
Dim c2 As New Class2
c2.TheFinalList = myArrayList
-
Aug 17th, 2009, 04:18 AM
#9
Thread Starter
Addicted Member
Re: passing arrayllist value into another class
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
|