943,662 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 2535
  • VB.NET RSS
Oct 30th, 2007
0

Separating Names

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Magnusz is offline Offline
13 posts
since Oct 2007
Oct 30th, 2007
0

Re: Separating Names

>Tony J Holley

Does your name have three words in it always. Is each word separated by only one space. Please answer these questions.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Oct 30th, 2007
0

Re: Separating Names

Yeah Three names and Yes only one space between names.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Magnusz is offline Offline
13 posts
since Oct 2007
Oct 31st, 2007
0

Re: Separating Names

you can use split method in string class
VB.NET Syntax (Toggle Plain Text)
  1.  
  2.  
  3. Dim namepart(3) As String
  4. fullname = TextBox1.Text
  5.  
  6. For i = 0 To TextBox1.Text.Length - 1
  7. namepart = fullname.Split(" ")
  8. Next
  9. TextBox2.Text = namepart(0)
  10. TextBox3.Text = namepart(1)
  11. TextBox4.Text = namepart(2)

you can read more about array here and about string here
Last edited by manal; Oct 31st, 2007 at 2:47 am.
Reputation Points: 37
Solved Threads: 17
Junior Poster
manal is offline Offline
122 posts
since Mar 2006
Nov 1st, 2007
0

Re: Separating Names

It keeps telling me "i" is not declared ?
Last edited by Magnusz; Nov 1st, 2007 at 10:05 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Magnusz is offline Offline
13 posts
since Oct 2007
Nov 1st, 2007
0

Re: Separating Names

blah I got it, Thanks Manal , me without this site . THANKS AGAIN.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Magnusz is offline Offline
13 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: register page using SQL server
Next Thread in VB.NET Forum Timeline: can someone tell m whats the error!!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC