473,614 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1192
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).T oString)
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
8877
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
3435
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 in the list, how do I write this? Thanks!!! Mel
2
6380
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 displaying the Table names out of the datatable. Thanks for any assistance you might be able to offer! Ron
25
5852
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
1679
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. After each practice session, the utility program tells the flashcard program which items were learned and whihc need more practice. The drill stats are trracked by 3 indices: user, subject, and item.
4
1139
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 directive and a public property in page1. My problem is: how can I access the arraylist in page1 from page3? I tried to define a public property in page2 that returns "previouspage.arraylist" but it doesn't work. Any idea?
1
9336
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)); and set it in request httpservletrequest.setAttribute("list", list); and Double double1 = new Double(s7); String f = double1.floatValue();
3
2119
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; ArrayList req=(ArrayList) request.getAttribute("req"); for(Iterator it= req.iterator();it.hasNext();){ prfObj=(PendingReqForm) it.next();{ %>
4
3608
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 condition. How do i go about asking c++ to find the subsets and then check?? Thanks: Patrick
0
8179
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8124
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8621
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8272
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8427
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6087
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5538
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4119
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1421
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.