Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

String manipulation

Posted on 1998-11-18
4
Medium Priority
?
148 Views
Last Modified: 2010-05-03
I wish to be able to take names (first, MI, and last) from a data file and convert each one of them into one of the following forms: LastName, FirstName or LastName, FirstName MiddleInitial where LastName and FirstName begin with a capital letter and have all the rest of their characters in lower case and MiddleInitial is a single character, capitalized.  william ANDreW CliNToN would become Clinton, William A.  
0
Comment
Question by:wkumad
4 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1445453
And what is your question?
0
 
LVL 14

Accepted Solution

by:
Matti earned 150 total points
ID: 1445454
Public Function ChaName(name As String)
Dim restofit$, lenghtofname&, firstletter As String * 1
name = LCase(name)
lenghtofname = Len(name) - 1
firstletter = UCase(name)
restofit = Mid$(name, 2, lenghtofname)
name = firstletter & restofit
End Function

There is a simple function for modulle level


Dim x&
x = ChaName(testdata)

this testdata is your orginal string variable holding the sting
to be converted.

*Note use a long variable whit the function call
if you use Call keyword it may stil work, but it may also get nested.

0
 
LVL 3

Expert Comment

by:jbil
ID: 1445455
This assumes you have already loaded values from data base and dimmed variables.

First = "william"
MI = "ANDreW"
Last = "CliNToN"

lastname = Left$(UCase(Last), 1) & Right$(LCase(Last), Len(Last) - 1) & ", "
firstname = Left$(UCase(First), 1) & Right$(LCase(First), Len(First) - 1) & " "
middleinitial = Left$(UCase(MI), 1) & "."
newstr = lastname & firstname & middleinitial
Debug.Print newstr
0
 

Author Comment

by:wkumad
ID: 1445456
I also valued jbil's proposal and may use a combination of it and Matti's answer.

                                                                                           Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

927 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