<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Populate ListBox from Text File - Without Repeats in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/populate-listbox-from-text-file-without-repeats/m-p/2368270#M17522</link>
    <description>I got it. Here's the code if anyone's interested. The first item in the array is left blank, so at the end, I check for a blank entry before populating the list.  I use a listbox and a command button on my test form.&lt;BR /&gt;&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;
Private Sub Command1_Click()&lt;BR /&gt;&lt;BR /&gt;
Dim FN As Long&lt;BR /&gt;&lt;BR /&gt;
Dim Lister() As String&lt;BR /&gt;&lt;BR /&gt;
Dim Inc As Integer&lt;BR /&gt;&lt;BR /&gt;
Dim booMatch As Boolean&lt;BR /&gt;
&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;
FN = FreeFile&lt;BR /&gt;&lt;BR /&gt;
Open "Textfile.txt" For Input As #FN&lt;BR /&gt;&lt;BR /&gt;
Inc = 0&lt;BR /&gt;&lt;BR /&gt;
ReDim Preserve Lister(0)&lt;BR /&gt;&lt;BR /&gt;
Do While Not EOF(FN)&lt;BR /&gt;&lt;BR /&gt;
    Line Input #FN, linestring&lt;BR /&gt;&lt;BR /&gt;
        booMatch = False&lt;BR /&gt;&lt;BR /&gt;
        For lp = 0 To UBound(Lister)&lt;BR /&gt;&lt;BR /&gt;
            If Lister(lp) = linestring Then booMatch = True&lt;BR /&gt;&lt;BR /&gt;
        Next lp&lt;BR /&gt;&lt;BR /&gt;
        If booMatch = False Then&lt;BR /&gt;&lt;BR /&gt;
            Inc = Inc + 1&lt;BR /&gt;&lt;BR /&gt;
            ReDim Preserve Lister(Inc)&lt;BR /&gt;&lt;BR /&gt;
            Lister(Inc) = linestring&lt;BR /&gt;&lt;BR /&gt;
        End If&lt;BR /&gt;&lt;BR /&gt;
Loop&lt;BR /&gt;&lt;BR /&gt;
Close FN&lt;BR /&gt;&lt;BR /&gt;
With List1&lt;BR /&gt;&lt;BR /&gt;
    .Clear&lt;BR /&gt;&lt;BR /&gt;
    For lp = 0 To UBound(Lister)&lt;BR /&gt;&lt;BR /&gt;
        If Lister(lp) &amp;lt;&amp;gt; "" Then .AddItem Lister(lp)&lt;BR /&gt;&lt;BR /&gt;
    Next lp&lt;BR /&gt;&lt;BR /&gt;
    .ListIndex = 0&lt;BR /&gt;&lt;BR /&gt;
End With&lt;BR /&gt;&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;/P&gt;</description>
    <pubDate>Fri, 24 Oct 2008 14:29:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-10-24T14:29:39Z</dc:date>
    <item>
      <title>Populate ListBox from Text File - Without Repeats</title>
      <link>https://forums.autodesk.com/t5/vba-forum/populate-listbox-from-text-file-without-repeats/m-p/2368269#M17521</link>
      <description>I've seen many examples of populating a listbox from a text file, but my text file will have many repeats of the same items, and I'd like to weed these out, and just have a list of available items, with no repeats.&lt;BR /&gt;
&lt;BR /&gt;
I'm presently working on the code, so I don't have anything to post yet.  My present idea is to start an array with the first item from the text file, then compare the next item to the array entry, and if it does not match, then add it to the array.  As the array grows, the text item will be compared to each item in the array, discarding any matches and adding any new items.&lt;BR /&gt;
&lt;BR /&gt;
I'm sure I'll figure it out, but if anyone has something that's already done, I'd appreciate handouts.  I'll post whatever I come up with if there are no responses.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Fri, 24 Oct 2008 14:01:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/populate-listbox-from-text-file-without-repeats/m-p/2368269#M17521</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-10-24T14:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Populate ListBox from Text File - Without Repeats</title>
      <link>https://forums.autodesk.com/t5/vba-forum/populate-listbox-from-text-file-without-repeats/m-p/2368270#M17522</link>
      <description>I got it. Here's the code if anyone's interested. The first item in the array is left blank, so at the end, I check for a blank entry before populating the list.  I use a listbox and a command button on my test form.&lt;BR /&gt;&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;
Private Sub Command1_Click()&lt;BR /&gt;&lt;BR /&gt;
Dim FN As Long&lt;BR /&gt;&lt;BR /&gt;
Dim Lister() As String&lt;BR /&gt;&lt;BR /&gt;
Dim Inc As Integer&lt;BR /&gt;&lt;BR /&gt;
Dim booMatch As Boolean&lt;BR /&gt;
&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;
FN = FreeFile&lt;BR /&gt;&lt;BR /&gt;
Open "Textfile.txt" For Input As #FN&lt;BR /&gt;&lt;BR /&gt;
Inc = 0&lt;BR /&gt;&lt;BR /&gt;
ReDim Preserve Lister(0)&lt;BR /&gt;&lt;BR /&gt;
Do While Not EOF(FN)&lt;BR /&gt;&lt;BR /&gt;
    Line Input #FN, linestring&lt;BR /&gt;&lt;BR /&gt;
        booMatch = False&lt;BR /&gt;&lt;BR /&gt;
        For lp = 0 To UBound(Lister)&lt;BR /&gt;&lt;BR /&gt;
            If Lister(lp) = linestring Then booMatch = True&lt;BR /&gt;&lt;BR /&gt;
        Next lp&lt;BR /&gt;&lt;BR /&gt;
        If booMatch = False Then&lt;BR /&gt;&lt;BR /&gt;
            Inc = Inc + 1&lt;BR /&gt;&lt;BR /&gt;
            ReDim Preserve Lister(Inc)&lt;BR /&gt;&lt;BR /&gt;
            Lister(Inc) = linestring&lt;BR /&gt;&lt;BR /&gt;
        End If&lt;BR /&gt;&lt;BR /&gt;
Loop&lt;BR /&gt;&lt;BR /&gt;
Close FN&lt;BR /&gt;&lt;BR /&gt;
With List1&lt;BR /&gt;&lt;BR /&gt;
    .Clear&lt;BR /&gt;&lt;BR /&gt;
    For lp = 0 To UBound(Lister)&lt;BR /&gt;&lt;BR /&gt;
        If Lister(lp) &amp;lt;&amp;gt; "" Then .AddItem Lister(lp)&lt;BR /&gt;&lt;BR /&gt;
    Next lp&lt;BR /&gt;&lt;BR /&gt;
    .ListIndex = 0&lt;BR /&gt;&lt;BR /&gt;
End With&lt;BR /&gt;&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;/P&gt;</description>
      <pubDate>Fri, 24 Oct 2008 14:29:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/populate-listbox-from-text-file-without-repeats/m-p/2368270#M17522</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-10-24T14:29:39Z</dc:date>
    </item>
  </channel>
</rss>

