Try this code, ofcourse this is meant for a combobox but I am sure someone can do this for listbox. I would have done it but don't have VB installed on the computer I am serfing the net from
VB Code:
Private Const CB_FINDSTRINGEXACT = &H158 Private Const CB_ERR = (-1) Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, lParam As Long) As Long Private Sub cmdRemoveDups() Dim x As Integer, y As Integer For x = cmbSortServiceDate.ListCount - 1 To 0 Step (-1) y = SendMessage(cmbSortServiceDate.hwnd, CB_FINDSTRINGEXACT, CB_ERR, ByVal cmbSortServiceDate.List(x)) If y <> x And y <> CB_ERR Then cmbSortServiceDate.RemoveItem x End If Next End Sub





Reply With Quote