Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Changing arraylist values

Posted on 2012-09-14
2
Medium Priority
?
535 Views
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?
0
Comment
Question by:DColin
2 Comments
 
LVL 60

Assisted Solution

by:Julian Hansen
Julian Hansen earned 1000 total points
ID: 38398333
The simple approach
Dim al As New ArrayList()
        al.Add(1)
        al.Add(21)
        al.Add(12)
        al.Add(7)
        For i = 0 To al.Count - 1
            If al(i) < 10 Then
                al(i) = 0
            End If
        Next

Open in new window

0
 
LVL 20

Accepted Solution

by:
n2fc earned 1000 total points
ID: 38398336
' 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 
Next

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

810 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