Results 1 to 3 of 3

Thread: List Box Problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Post

    I have 2 List Boxes. I am moving a few items from List1 to List2. However, if I try moving these items back into List1 an empty item at the top of List 1 appears. How can I get rid of this invisible item. The code is as follows:

    Private Sub cmdAdd_Click()

    Dim i As Integer

    List2.AddItem List1.Text

    i = List1.ListIndex

    If i >= 0 Then List1.RemoveItem i

    List1.ListIndex = 0

    End Sub


    Private Sub cmdRemove_Click()

    Dim j

    List1.AddItem (List2.Text)

    j = List2.ListIndex

    If j >= 0 Then List2.RemoveItem j

    End sub

    Any ideas ?

  2. #2
    Member
    Join Date
    Oct 1999
    Posts
    32

    Post

    Comment the last line of sub cmdadd_click

  3. #3
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    Test it:

    -------------
    Private Sub cmdAdd_Click()

    Dim i As Integer

    i = List1.ListIndex
    If i < 0 Then Exit Sub

    List2.AddItem List1.Text
    List1.RemoveItem i
    If List1.ListCount = 0 Then Exit Sub
    If i = 0 Then i = 0 Else i = i - 1
    List1.ListIndex = i
    List1.SetFocus

    End Sub

    Private Sub cmdRemove_Click()

    Dim i

    If i < 0 Then Exit Sub

    List1.AddItem List2.Text
    List2.RemoveItem i
    If List2.ListCount = 0 Then Exit Sub
    If i = 0 Then i = 0 Else i = i - 1
    List2.ListIndex = i
    List2.SetFocus

    End Sub

    ------------------
    smalig
    [email protected]
    smalig.tripod.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width