Results 1 to 3 of 3

Thread: ListBoxes

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    5

    Cool

    Hi again. I'm in a bit of trouble. The project I'm working on needs the use of listboxes, but I haven't the slightest idea how to use them. Could anyone give me a quick overview?

    --
    VB6 Professional

  2. #2
    Hyperactive Member
    Join Date
    Dec 1999
    Posts
    321

    Lightbulb Quick overview

    Okay, here are the most usable functions of a listbox, to try this project, do the following:

    - Make a new project

    - Add a listbox-control

    - Add three command-buttons

    - Add this code:

    Code:
    Private Sub Command1_Click()
    List1.AddItem InputBox("Type something", "New list item", "hello world")
    End Sub
    
    Private Sub Command2_Click()
    For x = 0 To List1.ListCount - 1
        If List1.ListCount = 0 Then Exit For
        If List1.Selected(x) Then
            MsgBox "The data: " & List1.List(x) & " is selected."
            Exit For
        End If
    Next x
    End Sub
    
    Private Sub Command3_Click()
    List1.Clear
    End Sub
    Hitting the first button will ask you for any text which will be added as a row in the listbox. The second button will show you what's selected, if empty or if none selected it doesn't do anything. Third button will clear the listbox.


    This should get your running...
    Signed, Rodik ([email protected])
    Programmer,usesVB6ED
    ===========================
    Copyright©RodikCo,2002.

    Dont mind this signature ;] Its old

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb

    By the way, what you need to do with the ListBox Control? The ListBox control only can list all the Item that you've added into thier list, either at Design Time or Runtime.

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