Link to home
Start Free TrialLog in
Avatar of comtech1234
comtech1234

asked on

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.
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

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

Avatar of comtech1234
comtech1234

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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