Saint Nick
Lifer
How would I go about splitting up the contents of a text box into two strings? Here's what I'm talking about:
Originally posted by: mayest
This may be more complex than you think. I do something very similar in a VBA program for Excel. For my purposes, I just need to extract the last name. So, I look for the first space in the string using the InStr (in string) function. That gives me the position of the space, then I take the right side of the string from the location of the space. It is only two lines of code (I don't know if the functions are identical in VB):
Pos = InStr(Name, " ")
Last= Right(Name, Len(Name) - Pos)
This works fine for me, but I don't need absolute perfection. There are a ton of potential problems. For example, what if somebody types in "Bob F. Jones" instead of "Bob Jones"? Then, using my code you will get "F. Jones" for the last name. There are other potential errors as well.
I think you might be better off having two text boxes (First and Last) rather than just one for the name. This will be much easier than coming up with an algorithm that will work in every conceivable case.