Solved

How do I delete an element from an array

Posted on 2009-05-17
7
408 Views
Last Modified: 2013-11-27
I have 2 arrays, FileList1 and FileList2. As I compare the 2, I want to delete any entries in FileList1 that are also in FileList2.

I found an answer at http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23721653.html but I get the error "RemoveAt is not a member of System.Array"

It seems to have worked for a previous questioner so why not for me?

I am using Visual Studio Express 2008, (Visual Basic).
Dim FileList1(count1) As String ' Count1 is determined by some previous code

            Dim FileList2(count2) As String ' Count2 is determined by some previous code
 

            ' Code to populate the arrays

 

           If FileList1.Count > FileList2.Count Then

                For i As Integer = FileList1.Count - 1 To 0 Step -1

                    For x As Integer = FileList2.Count - 1 To 0 Step -1

                        If FileList2(x).ToString = FileList1(i).ToString Then

                            FileList1.RemoveAt(i)

                            Exit For 

                        End If

                    Next

                Next

            End If

Open in new window

0
Comment
Question by:jindalee
7 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 24405894
Consider using an ArrayList instead of Array. Then you can use the RemoveAt method.

Wayne
0
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24406116
As Webtubbs said, Array is not resizable. You have to use arraylist to add or remove items dynamically.
0
 
LVL 22

Expert Comment

by:p_davis
ID: 24423639
the asker in the pointer actually says that he has 2 arraylists.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Author Comment

by:jindalee
ID: 24465806
OOPS. So it does :S
0
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24467090
Mr.jindalee,

the link you provided has used arraylist.I think you are using arrays.Right?
0
 
LVL 1

Author Comment

by:jindalee
ID: 24600854
Haven't forgotten the question - I've been diverted to a higher priority task and haven't had the chance to try the suggestions. Will get back to it soon.
0
 
LVL 1

Author Closing Comment

by:jindalee
ID: 31582344
As soon as I changed from Array to ArrayList I was able to twek the code to do what I needed.

Thank you
0

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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

17 Experts available now in Live!

Get 1:1 Help Now