StrConv first character inside ()

S

shank

I'm using StrConv to set my string to proper case, but the first character
inside a parenthesis is lower case.
How can I set them to Upper case?
thanks!
 
K

Ken Snell

This is a bit tricky. Will each string have a string inside parentheses? Or
just some?

My first approach would be to use additional VBA code steps to handle this
situation:

Dim intLoc As Integer
StringVariable = StrConv(StringVariable, vbProperCase)
intLoc = InStr(StringVariable, "(")
If intLoc > 0 Then StringVariable = Left(StringVariable, intLoc) & _
Replace(Mid(StringVariable, intLoc + 1, 1), _
UCase(Mid(StringVariable, intLoc + 1, 1)) & _
Mid(StringVariable, intLoc + 2)
 
K

Ken Snell

Sorry -- just saw a typo in my post:

Dim intLoc As Integer
StringVariable = StrConv(StringVariable, vbProperCase)
intLoc = InStr(StringVariable, "(")
If intLoc > 0 Then StringVariable = Left(StringVariable, intLoc) & _
Replace(Mid(StringVariable, intLoc + 1, 1), _
UCase(Mid(StringVariable, intLoc + 1, 1)), , , vbTextCompare) & _
Mid(StringVariable, intLoc + 2)
 

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