|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Selecting just part of a ListBox's Text
In my listbox, I'm displaying multiple rows of the following [it's a 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 would display both "city" and "phone" in the caption...I would like to display just the "city". |
|
#2
|
|||
|
|||
|
Mybe your displayed content is so long to the listbox can't show the whole line string!..U can use textbox or other control which can show more string with scrollbar..
|
|
#3
|
|||
|
|||
|
label1.caption = myFunction(ListBox1.text)
private myFunction(inParm) as string Dim MyString as string MyString = Split(inParm, " ", -1, 1) ' MyString(0) contains "rs(city) value". ' MyString(1) contains "rs(phone) value". myFunction = MyString(0) 'city end myFunction I haven't tested the code. I'm not sure if " " is a valid deliminator for the split function. If it gives you a problem, maybe you can use an ascii code instead of " ". Hope this helped |
|
#4
|
|||
|
|||
|
U can use this code to show "city" in the caption of the label:
dim strarr as string if (listbox.text<>"") and (instr(listbox," ")>0) then strarr=split(listbox.text," ") label1.caption =strarr(0) else label1.caption="" end if |
|
#5
|
||||
|
||||
|
CP's code should work for what you want it to do. Just use the Listbox.list(Listbox.listindex) code to select your string that you want to deal with like we had discussed before
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Selecting just part of a ListBox's Text |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|