Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » General

Post new topic   Reply to topic
How to split string from listbox?
View previous topic :: View next topic  
Author Message
alexltkv
Regular


Joined: 08 Jul 2005
Posts: 61
Location: Iraq

PostPosted: Mar 15th, 2006 10:06 AM    Post subject: How to split string from listbox? Reply with quote

Hello,
my question is if I have a name of a person say John Doe in a listbox, how can I split the name so I can put John in text1 and Doe in text2.

Any help would be great. THANXS!
_________________
You're not a CYBERHOLIC... if you look for the Soup of the Day in the Format menu.
Back to top
View user's profile Send private message
dougthomas
Moderator


Joined: 27 Jul 2005
Posts: 271
Location: Essex, UK

PostPosted: Mar 17th, 2006 08:20 AM    Post subject: Reply with quote

Hi,

If the names are separated by a space the easiest way would be to use split
eg
Code:

Dim strNames() as String
strNames = Split(ListBox.List(1)," ")
Text1.text = strNames(0)
Text2.text = strNames(1)

Would split the name in the 2nd entry of ListBox into the two text boxes

Regards
Doug
_________________
If you can see the light at the end of the tunnel, it probably means there's a Train coming.
Back to top
View user's profile Send private message
alexltkv
Regular


Joined: 08 Jul 2005
Posts: 61
Location: Iraq

PostPosted: Mar 18th, 2006 07:21 AM    Post subject: Reply with quote

Thanks for your help. After your reply I found another code to split list text and It's a little different than yours.

Code:

Dim arrTmp
arrTmp = Split(list1.List(list1.ListIndex))
Text1.Text = arrTmp(0)
Text2.Text = arrTmp(1)

if Ubound(arrTmp)>0 then
Text2.Text = arrTmp(Ubound(arrTmp))
End If


What is the difference? (If any).
_________________
You're not a CYBERHOLIC... if you look for the Soup of the Day in the Format menu.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » General All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic