need help with listboxs

  • 15 years ago

    hey guys.... m totally new to this and i need all the help i can get...
    right now m stuck trying to remove from a listbox using the itemdata property.
    i know the itemdata and now i have to remove that from the list box....

    can someone help me with that....its urgent...






      




  • 15 years ago

    Try

    Private Sub cmdLoad_Click()
        Dim r As Long
       
        With List1
            For r = 1 To 10
                .AddItem "Entry " & r
                .ItemData(.NewIndex) = r  'But could be anything
            Next
        End With
    End Sub








    Private Sub cmdTest_Click()
        DeleteListItem 4
    End Sub

    Private Sub DeleteListItem(lngItemData As Long)
        Dim r As Long

        With List1
            For r = 0 To .ListCount - 1
                If .ItemData(r) = lngItemData Then
                    'Do something, in this case remove item
                    .RemoveItem r
                    Exit For
                End If
            Next
        End With
    End Sub








    Regards

    Chris

  • 15 years ago

    thanks man....for your help....

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Never trust a programmer in a suit.” - Anonymous