[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I delete an element from an array

Posted on 2009-05-17
7
Medium Priority
?
422 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 48

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 2000 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

867 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