Question Help parsing name fields

VBscholar

New member
Joined
Mar 16, 2011
Messages
4
Programming Experience
Beginner
I'm creating a text file from values stored in a database. The text file output must contain a first and last name column. I'm having an issue parsing the suffix value from the name fields. Some of the first name values contain a suffix. I need to parse the first name column and move the suffix to the last name column if one exist. Can someone assist with moving the suffix from the first name column and appending to the last column?
 
Example of a suffix?

Check out the String.Split(), String.IndexOf(), String.Substring, String.Concat() methods. These should help you split the first name off from its suffix (after you identify what it is) and Concatenate it onto the last name.
 
How would I check to see if the string contained (JR, III, SR, etc..)? Would I have to write separate statements to check for each suffix value or can I do something similar to the SQL statement "Select from table where in ('JR', 'III','SR'). Would I need a case statement to do this?

Here is an example of the values in my name columns:

FirstName
1.John JR
2.John
3.John III
4.John

LastName
1.Doe
2.Doe SR
3.Doe
4.Doe IV
 
Last edited:
Pseudocode.
VB.NET:
Select firstName
     Case III, JR, .....
          dim suffix as string = firstname.substring(..indexOf() last space to end?)
          lastname = lastname & suffix
          firstname = firstname.replace(suffix, "")
End Select
You could use an if statement as well, you just mentioned the select so figured I'd use it.
 
Back
Top