Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Posts
    22

    Unanswered: Selecting on the ListBox

    When I try to display the text selected from a ListBox onto the caption of a label, I get the "Compile error: Argument not optional". Below is the code I'm using, please help:


    Private Sub ListBox2_Click()

    Label17.Caption = ListBox2.Selected

    End Sub


    Thanks.

  2. #2
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    2
    Try Label17.Caption = ListBox2.List(ListBox2.ListIndex)

  3. #3
    Join Date
    Nov 2003
    Posts
    22
    Another question:

    In my listbox, I'm displaying multiple rows of the following [it's the result of a query sent to Oracle]:

    ListBox.AddItem rs("city") & (" ") & rs("phone")

    When the user clicks on the ListBox, I would like to have just "city" (not "phone") of that particular selected entry displayed on Label1.Caption. How can I do that? Please help. Thanks.

    P.S. Label1.Caption = ListBox.Text OR Label1.Caption = ListBox.List(ListBox.ListIndex) would display both "city" and "phone" in the caption...I would like to display just the "city".
    Last edited by VB_Oracle; 11-27-03 at 04:16.

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    What is the format of the city and telephone ?

  5. #5
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    2
    if you use a specific character in between the two fields, you can use the function Split to get the different parts later on

  6. #6
    Join Date
    Feb 2002
    Posts
    2,232
    Label17.Caption = ListBox2.Selected
    This requires an index to validate whether that item has been selected. Use can use:

    label17.caption = listbox2.text

Posting Permissions

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