Re: Surprise in StrConv using vbProperCase
From: Ken Snell [MVP] (kthsneisllis9_at_ncoomcastt.renaetl)
Date: 11/09/04
- Next message: Derek Wittman: "Controlling Excel"
- Previous message: anonymous_at_discussions.microsoft.com: "Append & Update Table"
- In reply to: Gary Schuldt: "Surprise in StrConv using vbProperCase"
- Next in thread: Gary Schuldt: "Re: Surprise in StrConv using vbProperCase"
- Reply: Gary Schuldt: "Re: Surprise in StrConv using vbProperCase"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 9 Nov 2004 09:22:42 -0500
Try this (the behavior you note for StrConv is a commonly discussed issue
here in the newsgroups):
Public Function CapFirstLetter(strString As String) As String
Dim strLetter As String
strLetter = Left(strString, 1)
Select Case Asc(strLetter)
Case 97 To 122
strLetter = Chr(Asc(strLetter) - 32)
End Select
CapFirstLetter = strLetter & Mid(strString, 2)
End Function
--
Ken Snell
<MS ACCESS MVP>
"Gary Schuldt" <garyschuldt@comcast.net> wrote in message
news:%23Jk0epjxEHA.1452@TK2MSFTNGP11.phx.gbl...
> VBA Help says using the vbProperCase option in the StrConv function
converts
> the first letter of every word to uppercase.
>
> The surprise is that it converts all other characters to lower case!
>
> This is an *unpleasant* surprise in my application, because it changes
> "O'Malley" to "O'malley", which I don't want.
>
> I just want a function to capitalize the first letter of each word and
leave
> the other letters alone. Anyone know of such a function so I don't have
to
> code it myself?
>
> Gary
>
>
- Next message: Derek Wittman: "Controlling Excel"
- Previous message: anonymous_at_discussions.microsoft.com: "Append & Update Table"
- In reply to: Gary Schuldt: "Surprise in StrConv using vbProperCase"
- Next in thread: Gary Schuldt: "Re: Surprise in StrConv using vbProperCase"
- Reply: Gary Schuldt: "Re: Surprise in StrConv using vbProperCase"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|