Solved

String manipulation

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

726 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