Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: listbox remove item vb 6.0

Results 1 to 2 of 2
Share This Thread →
  1. #1
    gnanadurai is offline Registered User
    Join Date
    Jan 2004
    Location
    australia
    Posts
    2
    Rep Power
    0

    Unhappy listbox remove item vb 6.0

    why does when adding items to a list box all items are added according to index increment, but when items are removed only even items are removed????


    thanks for your help

    dave ...this is the code

    Private Sub Command1_Click()
    Dim Entry, i, Msg ' Declare variables.
    Msg = "Choose OK to add 100 items to your list box."
    MsgBox Msg ' Display message.
    For i = 1 To 100 ' Count from 1 to 100.
    Entry = "Entry " & i ' Create entry.
    Debug.Print Entry & " "
    List1.AddItem Entry ' Add the entry.

    Next i
    Msg = "Choose OK to remove every other entry."
    MsgBox Msg ' Display message.
    For i = 1 To List1.ListCount ' Determine how to


    Debug.Print List1.ListIndex

    Debug.Print List1.ListIndex
    List1.RemoveItem (i)

    Next i ' item.


    Msg = "Choose OK to remove all items from the list box."
    MsgBox Msg ' Display message.
    List1.Clear ' Clear list box.

    End Sub

  2. #2
    rletanab is offline Registered User
    Join Date
    Dec 2003
    Location
    Philippines
    Posts
    21
    Rep Power
    0
    try this one.

    Private Sub Command1_Click()
    Dim Entry, i, Msg ' Declare variables.
    Msg = "Choose OK to add 100 items to your list box."
    MsgBox Msg ' Display message.
    For i = 1 To 100 ' Count from 1 to 100.
    Entry = "Entry " & i ' Create entry.
    Debug.Print Entry & " "
    List1.AddItem Entry ' Add the entry.

    Next i
    Msg = "Choose OK to remove every other entry."
    MsgBox Msg ' Display message.
    While List1.ListCount > 0 ' Determine how to
    Debug.Print List1.ListIndex
    Debug.Print List1.ListIndex
    List1.RemoveItem (List1.ListCount - 1)

    Wend
    End Sub

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

  1. Replies: 2
    Last Post: September 24th, 2004, 01:18 PM
  2. Replies: 1
    Last Post: December 10th, 2003, 04:55 AM
  3. Request URL from catalogue item
    By Em Rave in forum ASP Development
    Replies: 1
    Last Post: October 19th, 2003, 01:21 PM
  4. How will I know which item is selected in a list box?
    By Steve Schofield in forum ASP Development
    Replies: 3
    Last Post: July 2nd, 2003, 08:00 PM
  5. VBScript and VB programmers thrown in trash heap by Microsoft
    By Steve Schofield in forum .NET Development
    Replies: 3
    Last Post: July 18th, 2000, 03:55 PM

ASP Free Advertisers and Affiliates