rather basic ?.. brain dead....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aussie Rules

    #1

    rather basic ?.. brain dead....

    Hi,

    i have a list box with a number of items.

    I want the user to be able to select a number of items, press the delete
    key, and they are delete. The following code does cause an error....

    I guess i must be doing it wrong, but can't think how else to go about the
    delete (after trapping the delete keydown)

    ----
    Dim indx As clsInspectionTi me

    For Each indx In lstInspectionti mes.SelectedIte ms

    lstInspectionti mes.Items.Remov e(indx)

    Next






  • Herfried K. Wagner [MVP]

    #2
    Re: rather basic ?.. brain dead....

    "Aussie Rules" <nobody@whocare s.com> schrieb:[color=blue]
    > I want the user to be able to select a number of items, press the delete
    > key, and they are delete.[/color]

    See:

    <URL:http://groups.google.d e/group/microsoft.publi c.dotnet.langua ges.vb/msg/534ed1f2a04ac51 0>

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Brian Henry

      #3
      Re: rather basic ?.. brain dead....

      when enumerating a collection, you can not change the enumeration... aka you
      cant remove items from it... so you will have to use the .count property of
      the selected items collection and move through them one by one until there
      is zero items in it... (this is not enumerating, only for each is)

      "Aussie Rules" <nobody@whocare s.com> wrote in message
      news:u$ktKpDfGH A.3888@TK2MSFTN GP04.phx.gbl...[color=blue]
      > Hi,
      >
      > i have a list box with a number of items.
      >
      > I want the user to be able to select a number of items, press the delete
      > key, and they are delete. The following code does cause an error....
      >
      > I guess i must be doing it wrong, but can't think how else to go about the
      > delete (after trapping the delete keydown)
      >
      > ----
      > Dim indx As clsInspectionTi me
      >
      > For Each indx In lstInspectionti mes.SelectedIte ms
      >
      > lstInspectionti mes.Items.Remov e(indx)
      >
      > Next
      >
      >
      >
      >
      >
      >[/color]


      Comment

      Working...