Changing arraylist values

Posted on 2012-09-14
Last Modified: 2012-09-14
Hi Experts,

If I had a list of integers stored in an arraylist and wanted to change any integers value to 0 if it were above 10 how would I do this?
Question by:DColin
    LVL 49

    Assisted Solution

    by:Julian Hansen
    The simple approach
    Dim al As New ArrayList()
            For i = 0 To al.Count - 1
                If al(i) < 10 Then
                    al(i) = 0
                End If

    Open in new window

    LVL 20

    Accepted Solution

    ' set n to number of elements in arrayList
    For index As Integer = 1 To n
        If arrayList(index) > 10 Then 
            arrayList(index) = 0
        End If 

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    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…

    759 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

    12 Experts available now in Live!

    Get 1:1 Help Now