I have looked around a couple of sites and found how to remove duplicates from a listbox but not how to send the duplicate free list of names over to a second listbox, an example of code i found

Private Sub ListBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Dim fd As New Dictionary(Of String, Integer)
        For Each filename As String In IO.Directory.GetFiles("c:\windows")
        Next
        For Each entry As KeyValuePair(Of String, Integer) In fd
            ListBox1.Items.Add(String.Format("{0} ({1})", entry.Key, entry.Value))
        Next
    End Sub

I'm not sure where you need Dictionary object, but if you want a list of unique file names, here's how I would do it

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  '
  Dim FileNames() As String
  Dim FileName As String
  
  FileNames = IO.Directory.GetFiles("c:\windows")
  For Each FileName In FileNames
    If ListBox1.Items.IndexOf(FileName) < 0 Then
      ListBox1.Items.Add(FileName)
    End If
  Next

End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.