Updating Text Boxes to have 1st Letter as Capital

D

DMc2004

Hi

What I would like to know is how to convert names like smith, brown, adams,
etc to Smith, Brown and Adams when a user inputs all the data as lower case.
This i want to do after the user has entered the data into the text box.

D.
 
G

Guest

If the text box contains only the surname, you could try code along the
following lines in the text box's AfterUpdate eventHandler

txtName.Value = UCase(Left$(txtName,1)) & Mid$(txtName,2)

where txtName is the name of the text box.

If it contains first names and a surname and you want all the parts to have
the first letter capitalised, you could try the following

Dim lngSub As Long
Dim strName() As String
Dim strResult As String

strName = Split(txtName.Value, " ")

For lngSub = 0 to UBound(strName)
strResult = strResult & UCase(Left$(strName(lngSub),1)) &
Mid$(strName(lngSub),2) & " "
Next

txtName.Value = Trim$(strResult)

Hope This Helps
Gerald Stanley MCSD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top