how to check an arralist with individual Alphanumeric entries.

I want to search an arraylist of entries and if an entry is is there do not duplicate the entry and jsut move on. If the entry is new I want to add it to the arraylist.

If _ExcelGageID.startswith("L")  then
_ExcelArraylist.add(wirelessArray(1)
end if

Open in new window

cmdolcetAsked:
Who is Participating?
 
Fernando SotoRetiredCommented:
Then this should work. Be aware that the alpha's must have the same case as what you are trying to insert otherwise it will not compare correctly.
Dim al As New ArrayList
'' ...
Dim itemToInset As String = "L4"

If Not al.Contains(itemToInset) Then
    al.Add(itemToInset)
End If

Open in new window

0
 
Fernando SotoRetiredCommented:
What kind of Object are stored in the ArrayList?
If not basic types such as integers, double, ... what is the object structure and what fields will determine equality?
0
 
Fernando SotoRetiredCommented:
Hi cmdolcet;

If using a basic data type such as integer then doing the following should do what you need.
Dim al As New ArrayList
'' ...
Dim itemToInset As Integer = 4

If Not al.Contains(itemToInset) Then
    al.Add(itemToInset)
End If

Open in new window

0
 
cmdolcetAuthor Commented:
Sorry just saw that. I am looking to add an alphanumeric number like "L12345" to the arraylist.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.