Im trying to Separate First Name, Middle Initial, and last name into Textboxes, with a function of a button.

Example :

Full Name : Tony J Holley

First Name: Tony
Middle Initial: J
Last Name: Holley

All I have is this, and is for the first name Separator:

' determines the person's first name
Dim name As String
name = txtfullname.Text
txtfirstname.Text = firstname(name)

End Sub
Function firstname(ByVal name As String) As String
Dim firstspace As Integer
firstspace = name.IndexOf(" ")
Return name.Substring(0, firstspace)

I don't know how to separate the middle Initial nor the Last name.

Thanks In Advance.

9 Years
Discussion Span
Last Post by Magnusz

>Tony J Holley

Does your name have three words in it always. Is each word separated by only one space. Please answer these questions.


you can use split method in string class

Dim namepart(3) As String
         fullname = TextBox1.Text

        For i = 0 To TextBox1.Text.Length - 1
            namepart = fullname.Split(" ")
        TextBox2.Text = namepart(0)
        TextBox3.Text = namepart(1)
        TextBox4.Text = namepart(2)

you can read more about array here and about string here


blah I got it, Thanks Manal :), me without this site :P. THANKS AGAIN.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.