Re: Surprise in StrConv using vbProperCase

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ken Snell [MVP] (kthsneisllis9_at_ncoomcastt.renaetl)
Date: 11/09/04


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
>
>


Relevant Pages

  • Re: Surprise in StrConv using vbProperCase
    ... Your code will capitalize the first letter of a string. ... so the specs for StrConv using vbProperCase match ...
    (microsoft.public.access.modulesdaovba)
  • Re: How do you remove all the symbols?
    ... Dim bArr() as Byte ... I notice you ReDim the bArrto 2 x string length, ... However I don't regard StrConv as a significant overhead. ... Dim strIn As String, strOut As String, s As String ...
    (microsoft.public.excel.programming)
  • trouble opening doc in preview mode with zoom 65%
    ... When user clicks button, print a word report, ... strTitle As String, _ ... strLetter = "FinalClearanceLetter3.doc" ... Set appWord = CreateObject ...
    (microsoft.public.word.vba.customization)
  • trouble opening doc in preview mode with zoom 65%
    ... When user clicks button, print a word report, ... strTitle As String, _ ... strLetter = "FinalClearanceLetter3.doc" ... Set appWord = CreateObject ...
    (microsoft.public.word.vba.customization)
  • Re: Write a file from binary data
    ... No strconv() will take any length string and convert it from one ... left(lcJPG, 20) ... > leave me with binary data where fwriteonly accepts character data? ...
    (microsoft.public.fox.programmer.exchange)