| View previous topic :: View next topic |
| Author |
Message |
alexltkv Regular
Joined: 08 Jul 2005 Posts: 61 Location: Iraq
|
Posted: Mar 15th, 2006 10:06 AM Post subject: How to split string from listbox? |
|
|
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 |
|
dougthomas Moderator
Joined: 27 Jul 2005 Posts: 271 Location: Essex, UK
|
Posted: Mar 17th, 2006 08:20 AM Post subject: |
|
|
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 |
|
alexltkv Regular
Joined: 08 Jul 2005 Posts: 61 Location: Iraq
|
Posted: Mar 18th, 2006 07:21 AM Post subject: |
|
|
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 |
|
|