Solved

String manipulation

Posted on 1998-11-18
4
145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 13

Expert Comment

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

Accepted Solution

by:
Matti earned 50 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

696 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