how to check an arralist with individual Alphanumeric entries.

cmdolcet
cmdolcet used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fernando SotoRetired
Distinguished Expert 2017

Commented:
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?
Fernando SotoRetired
Distinguished Expert 2017

Commented:
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

Author

Commented:
Sorry just saw that. I am looking to add an alphanumeric number like "L12345" to the arraylist.
Retired
Distinguished Expert 2017
Commented:
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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial