Apply "Name" Case to A String

mpappert

Well-known member
Joined
Oct 5, 2002
Messages
58
Location
Ottawa, ON, Canada
Again, another post to see if there is a better means for doing this ... I am taking a name such as "ashlyn" and making it read "Ashlyn" ...

[VB]
m_strFirstName = UCase$(Left$(m_strFirstName,1)) & Right$(m_strFirstName, Len(m_strFirstName) -1)
[/VB]

Thanks,
M.
 
m_strFirstName = m_strFirstName.Substring(0, 1).ToUpper() & m_strFirstName.Substring(1)
 
The ToTitleCase function of the TextInfo class can be used to
convert a string to Title Case (aka Proper Case), as so:

Code:
Dim cinfo As New Globalization.CultureInfo("en-US")

m_strFirstName = cinfo.TextInfo.ToTitleCase(m_strFirstName)
 
Back
Top