<?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: Looping problem in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339022#M84572</link>
    <description>As soon as you remove the first item, the ListCount becomes&lt;BR /&gt;
ListCount - 1 so you never reach the end of the list unless&lt;BR /&gt;
the end of the list is the only selected item. I know&lt;BR /&gt;
there's a way around but I'm drawing a blank at the moment.&lt;BR /&gt;
Sorry.&lt;BR /&gt;
&lt;BR /&gt;
--&lt;BR /&gt;
http://www.acadx.com</description>
    <pubDate>Thu, 03 May 2001 15:04:59 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2001-05-03T15:04:59Z</dc:date>
    <item>
      <title>Looping problem</title>
      <link>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339021#M84571</link>
      <description>Below is the code I have to remove selected items from a list box.  The problem is that if you select more than one item, the last item selected always remains.  I have tried different loops to accomplish this.  Any help would be greatly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Private Sub cmdRemoveFiles_Click()&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Dim i As Integer&lt;BR /&gt;
    For i = 0 To lstArchiveFiles.ListCount - 1&lt;BR /&gt;
        If lstArchiveFiles.Selected(i) = True Then&lt;BR /&gt;
            lstArchiveFiles.RemoveItem (i)&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next i&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Thank You,&lt;BR /&gt;
&lt;BR /&gt;
Jamie Gamauf</description>
      <pubDate>Thu, 03 May 2001 14:34:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339021#M84571</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-03T14:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem</title>
      <link>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339022#M84572</link>
      <description>As soon as you remove the first item, the ListCount becomes&lt;BR /&gt;
ListCount - 1 so you never reach the end of the list unless&lt;BR /&gt;
the end of the list is the only selected item. I know&lt;BR /&gt;
there's a way around but I'm drawing a blank at the moment.&lt;BR /&gt;
Sorry.&lt;BR /&gt;
&lt;BR /&gt;
--&lt;BR /&gt;
http://www.acadx.com</description>
      <pubDate>Thu, 03 May 2001 15:04:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339022#M84572</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-03T15:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Looping problem</title>
      <link>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339023#M84573</link>
      <description>&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Try this, Run the loop backwards that way the index &lt;BR /&gt;
numbers dont change as you remove items. substitute your&amp;nbsp;FOR statement with &lt;BR /&gt;
the one below. &lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;For i =&amp;nbsp;lstArchiveFiles.ListCount - 1&amp;nbsp;to &lt;BR /&gt;
0 Step -1 &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Paul H&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;jgamauf &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:jgamauf@ariainc.com"&amp;gt;jgamauf@ariainc.com&lt;/A&gt;&amp;gt; wrote in message &lt;BR /&gt;
  &lt;A&gt;&lt;BR /&gt;
  href="news:f049b6e.-1@WebX.maYIadrTaRb"&amp;gt;news:f049b6e.-1@WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;Below &lt;BR /&gt;
  is the code I have to remove selected items from a list box. The problem is &lt;BR /&gt;
  that if you select more than one item, the last item selected always remains. &lt;BR /&gt;
  I have tried different loops to accomplish this. Any help would be greatly &lt;BR /&gt;
  appreciated. &lt;BR /&gt;
  &lt;P&gt;Private Sub cmdRemoveFiles_Click() &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;On Error &lt;BR /&gt;
  Resume Next &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim i As Integer &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For i = 0 To lstArchiveFiles.ListCount - 1 &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If &lt;BR /&gt;
  lstArchiveFiles.Selected(i) = True Then &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lstArchiveFiles.RemoveItem &lt;BR /&gt;
  (i) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next i &lt;BR /&gt;End Sub &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Thank You, &lt;BR /&gt;
  &lt;/P&gt;&lt;P&gt;Jamie Gamauf&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 03 May 2001 15:46:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339023#M84573</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-03T15:46:05Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339024#M84574</link>
      <description>&lt;DIV&gt;Put zero(0) instead of i in this &lt;FONT&gt;&lt;BR /&gt;
color=#ff0000&amp;gt;lstArchiveFiles.RemoveItem (i)&lt;/FONT&gt; line.&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;BR /&gt;
&lt;P&gt;Private Sub cmdRemoveFiles_Click() &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;On Error &lt;BR /&gt;
Resume Next &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim i As Integer &lt;BR /&gt;
&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For i = 0 To lstArchiveFiles.ListCount - 1 &lt;BR /&gt;
&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If &lt;BR /&gt;
lstArchiveFiles.Selected(i) = True Then &lt;BR /&gt;
&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT&gt;&lt;BR /&gt;
color=#ff0000&amp;gt;lstArchiveFiles.RemoveItem (0)&lt;/FONT&gt; &lt;BR /&gt;
&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If &lt;BR /&gt;
&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next i &lt;BR /&gt;End Sub &lt;/P&gt;&lt;BR /&gt;-- &lt;BR /&gt;
&lt;BR /&gt;Madhanagopal&lt;BR /&gt;AutoCAD &amp;amp; MCAD Product Support, INDIA&lt;BR /&gt;WW Support &lt;BR /&gt;
&amp;amp; Services, Autodesk&lt;BR /&gt;Discussion Q&amp;amp;A: &lt;A&gt;&lt;BR /&gt;
href="http://www.autodesk.com/discussion"&amp;gt;http://www.autodesk.com/discussion&lt;/A&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"Paul H" &amp;lt;&lt;A href="mailto:paulh@rimex.com"&gt;paulh@rimex.com&lt;/A&gt;&amp;gt; &lt;BR /&gt;
  wrote in message &lt;A&gt;&lt;BR /&gt;
  href="news:829D2632616902D1567A1B63A806B5AF@in.WebX.maYIadrTaRb"&amp;gt;news:829D2632616902D1567A1B63A806B5AF@in.WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Try this, Run the loop backwards that way the &lt;BR /&gt;
  index numbers dont change as you remove items. substitute your&amp;nbsp;FOR &lt;BR /&gt;
  statement with the one below. &lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;For i =&amp;nbsp;lstArchiveFiles.ListCount - &lt;BR /&gt;
  1&amp;nbsp;to 0 Step -1 &lt;BR /&gt;
  &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Paul H&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;BLOCKQUOTE&gt;&lt;BR /&gt;
  style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
    &lt;DIV&gt;jgamauf &amp;lt;&lt;A&gt;&lt;BR /&gt;
    href="mailto:jgamauf@ariainc.com"&amp;gt;jgamauf@ariainc.com&lt;/A&gt;&amp;gt; wrote in &lt;BR /&gt;
    message &lt;A&gt;&lt;BR /&gt;
    href="news:f049b6e.-1@WebX.maYIadrTaRb"&amp;gt;news:f049b6e.-1@WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;Below &lt;BR /&gt;
    is the code I have to remove selected items from a list box. The problem is &lt;BR /&gt;
    that if you select more than one item, the last item selected always &lt;BR /&gt;
    remains. I have tried different loops to accomplish this. Any help would be &lt;BR /&gt;
    greatly appreciated. &lt;BR /&gt;
    &lt;P&gt;Private Sub cmdRemoveFiles_Click() &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;On Error &lt;BR /&gt;
    Resume Next &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim i As Integer &lt;BR /&gt;
    &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For i = 0 To lstArchiveFiles.ListCount - 1 &lt;BR /&gt;
    &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If &lt;BR /&gt;
    lstArchiveFiles.Selected(i) = True Then &lt;BR /&gt;
    &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lstArchiveFiles.RemoveItem &lt;BR /&gt;
    (i) &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If &lt;BR /&gt;
    &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next i &lt;BR /&gt;End Sub &lt;BR /&gt;
    &lt;/P&gt;&lt;P&gt;Thank You, &lt;BR /&gt;
    &lt;/P&gt;&lt;P&gt;Jamie Gamauf&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 04 May 2001 00:22:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339024#M84574</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-04T00:22:05Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339025#M84575</link>
      <description>&amp;gt; As soon as you remove the first item, the ListCount becomes&lt;BR /&gt;
&amp;gt; ListCount - 1 so you never reach the end of the list unless&lt;BR /&gt;
&amp;gt; the end of the list is the only selected item. I know&lt;BR /&gt;
&amp;gt; there's a way around but I'm drawing a blank at the moment.&lt;BR /&gt;
&lt;BR /&gt;
Without being able to see the code clearly amongst the "&amp;nbsp;"'s from &lt;BR /&gt;
what it looks like, you could do this be processing the list instead of &lt;BR /&gt;
from "0 - list length - 1" you'd use "list length - 1 to 0".&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
Y-------------------------------------------------------------------+&lt;BR /&gt;
| Darren J. Young                 | Minnesota CADWorks, Inc.        |&lt;BR /&gt;
|                 dyoung@mcwi.com | P.O. Box 7293                   |&lt;BR /&gt;
|              ftp://ftp.mcwi.com | St. Cloud, Minnesota 56302-7293 |&lt;BR /&gt;
|             http://www.mcwi.com | Phone 1-320-654-9053            |&lt;BR /&gt;
| CAD/CAM/CNC - Drafting Design Customization Training Programming  |&lt;BR /&gt;
0,0-----------------------------------------------------------------X&lt;BR /&gt;
Support the amendment to ban commercial unsolicited Email (SPAM) To&lt;BR /&gt;
join the fight, visit -&amp;gt; http://www.cauce.org/</description>
      <pubDate>Fri, 04 May 2001 06:18:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339025#M84575</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-04T06:18:54Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339026#M84576</link>
      <description>That would remove the first item in the list whether it is&lt;BR /&gt;
selected or not.&lt;BR /&gt;
&lt;BR /&gt;
--&lt;BR /&gt;
http://www.acadx.com&lt;BR /&gt;
&lt;BR /&gt;
"Madhanagopal" &lt;DISCUSSION&gt; wrote in message&lt;BR /&gt;
news:C93332EAC1D1E9FC2549B9044F54F80D@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Put zero(0) instead of i in this&lt;BR /&gt;
lstArchiveFiles.RemoveItem (i) line.&lt;BR /&gt;
&amp;gt; Private Sub cmdRemoveFiles_Click()&lt;BR /&gt;
&amp;gt;     On Error Resume Next&lt;BR /&gt;
&amp;gt;     Dim i As Integer&lt;BR /&gt;
&amp;gt;     For i = 0 To lstArchiveFiles.ListCount - 1&lt;BR /&gt;
&amp;gt;         If lstArchiveFiles.Selected(i) = True Then&lt;BR /&gt;
&amp;gt;             lstArchiveFiles.RemoveItem (0)&lt;BR /&gt;
&amp;gt;         End If&lt;BR /&gt;
&amp;gt;     Next i&lt;BR /&gt;
&amp;gt; End Sub&lt;/DISCUSSION&gt;</description>
      <pubDate>Fri, 04 May 2001 06:32:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339026#M84576</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-04T06:32:11Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339027#M84577</link>
      <description>Thanks alot Paul.  It works great!&lt;BR /&gt;
&lt;BR /&gt;
Jamie Gamauf</description>
      <pubDate>Fri, 04 May 2001 07:46:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/looping-problem/m-p/339027#M84577</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-04T07:46:21Z</dc:date>
    </item>
  </channel>
</rss>

