Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 27th, 2003, 02:11 AM
VB_Oracle VB_Oracle is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 18 VB_Oracle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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".

Reply With Quote
  #2  
Old November 27th, 2003, 03:05 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
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..

Reply With Quote
  #3  
Old November 27th, 2003, 08:15 AM
matos240 matos240 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 5 matos240 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old November 27th, 2003, 09:04 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
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

Reply With Quote
  #5  
Old November 27th, 2003, 11:28 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Selecting just part of a ListBox's Text


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT