[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Format Name String

Posted on 2006-06-08
5
Medium Priority
?
163 Views
Last Modified: 2010-04-30
Hello,
I am trying to create a form that is very similar to outlook's name dialog. When this form loads it takes the value from the variable MyString and I want it seperate the diffrent elements of a name into the following textboxes below. Although, not every person is going to have all the elements of a name.

Title
First
Middle
Last
Suffix
0
Comment
Question by:Gunit2507
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
List244 earned 2000 total points
ID: 16863941
Assuming your string is in the form:

"Title First Middle Last Suffix"
"Title First Middle Last"
"Title First Middle"
"Title First"
"Title"
Depending on how many they have:

Dim Splitter() As String
Splitter = Split(Data, " ")
For i = 0 To UBound(Splitter)
    Select Case (i)
        Case 0: Title.Text = Splitter(i)
        Case 1: First.Text = Splitter(i)
        Case 2: Last.Text = Splitter(i)
        Case 3: Middle.Text = Splitter(i)
        Case 4: Suffix.Text = Splitter(i)
    End Select
Next i

Where Data would be their name in the format: "Title First Middle Last Suffix"
0
 
LVL 8

Expert Comment

by:List244
ID: 16863948
That will allow you to split it into the boxes no matter how many of the allowed names they have.
From nothing to all of them without problem.
0
 
LVL 5

Expert Comment

by:patingsadagat
ID: 16866077
what if there's no title list244? it all depends on where the variable MyString came from Gunit2507. Was it an input or from a database.
0
 
LVL 8

Expert Comment

by:List244
ID: 16866092
Patingsadaqat, I do not know how his data comes in, which is why I said assuming it comes in in that way, my method would work.
If there were no title in the method I provided, then it would fill no text boxes.
0
 
LVL 5

Expert Comment

by:patingsadagat
ID: 16866495
given that way, it would definitely work list244.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month18 days, 7 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question