|
-
January 24th, 2005, 04:06 PM
#1
splitting names from db
hi
i need help finding a solution for my problem...
i reading names from a database field and i want to split them in 2 colums,
For Each DR In DT.Rows
sString = DR.Item("Customer")
Dim Name() As String = sString.Split(" ")
MsgBox(Name(0))
Next
works fine for names like smith john, with 2 words but suppose a name has 3 words like Van hagen John, you have 2 spaces. is their a way to see the last space so you can filter out the prename ?
tnx in advance
-
January 24th, 2005, 05:21 PM
#2
Re: splitting names from db
First suggestion would be to normalize your database. Second would be to use SubString() and IndexOf Methods to split up the string on the last space.
-
January 25th, 2005, 12:19 PM
#3
Re: splitting names from db
i can't really see how you can do that with those functions ? :s
can u give me an example pls?
Tnx
-
January 25th, 2005, 05:46 PM
#4
Re: splitting names from db
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Name As String = "Van Hagen John"
Dim First As String = Name.Substring(Name.LastIndexOf(" "))
Dim Last As String = Name.Substring(0, Name.LastIndexOf(" "))
MsgBox(First & "-" & Last)
End Sub
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
|