Navigating through an ArrayList

Posted on 2006-03-22
Last Modified: 2006-11-18
Hi All,

Ok, so now I have an ArrayList called RecordIDArray

It simply holds lots of record ID's.

I'm looking to navigate through it with 4 buttons.

- One for 'Next Record'
- One for 'Previous Record'
- One for 'Last Record'
- One for 'First Record'

What code would I use on these 4 buttons to move through my ArrayList?

Many thanks
Question by:ITranger
    LVL 5

    Accepted Solution

    Keep track of an index in a member variable such as:

    Dim CurrentIndex as integer = 0

    Now in each button figure out what action you need to take on that index:

    - One for 'Next Record'
          * Add one to the current index
          * if the currentindex > the = count of items in array -1 then set the current index to 0
          * redisplay data
    - One for 'Previous Record'
          * Subtract one from the current index
          * if the currentindex < 0 then set the currentindex = count of items in array -1
          * redisplay data
    - One for 'Last Record'
          * set the current index to the = count of items in array -1
    - One for 'First Record'
          * set the currentindex to 0

    Author Comment

    Ahh, I see - that member variable is key!


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now