Duplicate Compare with Output VB6

I have a listbox that looks like as follows

C027CF
C032AF
C032AR
C034AR
C036AF
C036AR

With the first letter of each line being the Aisle in a warehouse the number being the location, the second to last letter being the height location, and the last being the front of the location or the rear. I've been able to compare a complete list of all locations to a complete list of currently scanned locations to create a list of all empty pallet locations in the warehouse. WIth some aisles only being able to contain 1 pallet deep and some being to to handle 2. As you can notice with the above some have a single spot open and some have both the front and the rear. I want to find the duplicates then compare the end letter to see if its a true duplicate then output both of those lines so I know the location is truly empty for both the front and the rear. Locations with 1 pallet spot open mean nothing to me.
comtech1234Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
Assuming that the listbox is in sorted  order, this will output the matching pairs in message boxes
Option Explicit

Private Sub Command1_Click()
    Dim i As Integer
    
    For i = 0 To List1.ListCount - 1
        If Left(List1.List(i), 5) = Left(List1.List(i + 1), 5) Then
            MsgBox List1.List(i) & ", " & List1.List(i + 1)
        End If
    Next i
End Sub

Open in new window

comtech1234Author Commented:
So could I use this to create an array then do this again to split by the right side of listtext so I can keep the duplicate numbers ie: C025A, C025A then Match them together based on the end result C025AF, C025AR
GrahamSkanRetiredCommented:
You could create a two-dimensional array:
Option Explicit

Private Sub Command1_Click()
    Dim i As Integer
    Dim j As Integer
    Dim UsedShelves() As String

    For i = 0 To List1.ListCount - 1
        If Left(List1.List(i), 5) = Left(List1.List(i + 1), 5) Then
            ReDim Preserve UsedShelves(1, j)
            UsedShelves(0, j) = List1.List(i)
            UsedShelves(1, j) = List1.List(i + 1)
            j = j + 1
        End If
    Next i
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
comtech1234Author Commented:
Amazing time response. Experts exchange created the best possible answer in the fastest possible time. The code provided was on par with exactly what I needed. Thank you GrahamSkan
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.