Solved

String manipulation

Posted on 1998-11-18
4
139 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 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now