If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Selecting on the ListBox

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-26-03, 23:12
VB_Oracle VB_Oracle is offline
Registered User
 
Join Date: Nov 2003
Posts: 22
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.
Reply With Quote
  #2 (permalink)  
Old 11-27-03, 02:24
FjB FjB is offline
Registered User
 
Join Date: Oct 2003
Location: The Netherlands
Posts: 2
Try Label17.Caption = ListBox2.List(ListBox2.ListIndex)
Reply With Quote
  #3 (permalink)  
Old 11-27-03, 02:37
VB_Oracle VB_Oracle is offline
Registered User
 
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 03:16.
Reply With Quote
  #4 (permalink)  
Old 11-27-03, 06:02
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
What is the format of the city and telephone ?
Reply With Quote
  #5 (permalink)  
Old 11-28-03, 14:50
FjB FjB is offline
Registered User
 
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
Reply With Quote
  #6 (permalink)  
Old 11-29-03, 00:25
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Quote:
Label17.Caption = ListBox2.Selected
This requires an index to validate whether that item has been selected. Use can use:

label17.caption = listbox2.text
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On