473,386 Members | 1,726 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,386 software developers and data experts.

Retrieving subsets from an ArrayList

Hi,

How do you retrieve only a subset of items from an ArrayList using a
For...Next loop?

For instance, say I want to work only with 30 ArrayList items at a time.
After processing the 30 items, I'd like to retrieve the next 30 items and
process them. I'd like to continue doing it this way until all items have
been processed. How do I go about accomplishing this? I don't know where
to begin :-(

Thanks,
Roshawn
Nov 21 '05 #1
1 1189
Hi Roshawn,

Here is how you would do it in nested loops.

Dim al As ArrayList
al = New ArrayList(100)
Dim i As Integer
For i = 0 To 100
al.Add(i)
Next

Dim cntOuter As Integer
Dim cntInner As Integer
Dim NOuter As Integer
Dim NInner As Integer = 30
Dim NTotal As Integer = al.Count

If NTotal > NInner Then
NOuter = Math.Ceiling(al.Count / NInner)
End If
Dim nStart As Integer = 0
Dim nEnd As Integer

For cntOuter = 1 To NOuter
nEnd = cntOuter * NInner - 1
If nEnd > NTotal - 1 Then nEnd = NTotal - 1
For cntInner = nStart To nEnd
'Process your data
Debug.WriteLine(al(cntInner).ToString)
Next
nStart = nEnd + 1
Next

Hope this helps!
Bharat Patel
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.

Nov 21 '05 #2

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

Similar topics

7
by: Gaijinco | last post by:
I been thinking about this topic for a long time. The best I have done is the following code: #include <iostream> using namespace std; #include <cmath> int main(){ const int SIZE=3;
3
by: melanieab | last post by:
Hi, I can't seem to get the syntax correct. I have an xmlnodelist full of elements called "file". Each file has an attribute called "ID". If I just want to get, say, the ID of the second file...
2
by: RSH | last post by:
I am struggling a bit trying to get at all of the Table names in a given Access database. I have the code below which should be retrieving the information...i am just having a bit of trouble...
25
by: Jessica Weiner | last post by:
I have an array of n integers and I want a function that returns a list of arrays of all possible subsets. Can someone provide me with the code? Thanks. Jess
4
by: LurfysMa | last post by:
I could use some help with a table design problem. I have an electronic flashcard program. Actually, several of them. They each rely on a utility program to keep track of the usage statistics....
4
by: Giggi | last post by:
Hi! I have a little problem... I have 3 pages: users should go from page1 to page2 and then to page3 In page1 there is an arraylist, and I can access it from page2 using the PreviousPageType...
1
by: ajos | last post by:
Hi friends, In my class i have a ArrayList where i have stored the resultset data from the and also a float value i.e ive 2 arraylist. The way ive set the data is-- list.add(getData(resultset));...
3
by: ajos | last post by:
Hello friends, In my action class i am getting a resultset data which im storing in a arraylist. In my jsp page im retrieving the arraylist data as-----> <%publicity.PendingReqForm prfObj=null;...
4
by: Patrick | last post by:
Hi, I want to write a programs that checks if a set of numbers in a list obey a condition, the problem is that i have say "n" numbers and i need to check all subsets of the n numbers for the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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,...

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.