?
Solved

String manipulation

Posted on 1998-11-18
4
Medium Priority
?
146 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

771 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