|
-
Apr 11th, 2004, 03:09 PM
#1
Thread Starter
Registered User
Extracting from string
Hi
Can someone show me how to split a string and display each word in a label control?
For example, if I enter the name "Jenny Smith Kline" in a text box, I want to be able to get each name and display it in a different label control.
I know how to do it if there are only 2 names, e.g. "Jenny Smith", You just search for the "space" using the "instr" function.
I cant seem to do it with 3 names?
Please help
Last edited by jennysmith; Apr 11th, 2004 at 05:02 PM.
-
Apr 11th, 2004, 03:27 PM
#2
You can use Split().
VB Code:
Dim str As String = "Jenny Smith Kline"
Dim parts() As String = str.Split(Char.Parse(" "))
Label1.Text = parts(0)
Label2.Text = parts(1)
Label3.Text = parts(2)
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Apr 11th, 2004, 05:00 PM
#3
Thread Starter
Registered User
Wow, that code is cool, thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|