String manipulation

  • Thread starter Thread starter Jamenson
  • Start date Start date
J

Jamenson

Hi everyone in group!

I have a textbox in which people type customer clients. So, people
are typing like: "JESUS OF NAZARETH". I would like them to type
"Jesus of Nazareth" acording to the standard language rules, not
"Jesus Of Nazareth" ("O" capitalized) StrConv does.

Any help appreciated.
 
Jamenson,

Is it safe to assume that you are only wanting to do this under certain
conditions?

The reason that I ask this is that there are circumstances where you would
want to have all words capitalized: James Von Duke, Mary Lynn Smith, etc.

Are you only wanting to do the conversion for certain words like: of, the,
from, etc?

if this is the case, you can try using the following code in the AfterUpdate
event of the text box.

Dim strUserValue As String
Dim strStartVal As String
Dim strNewVal As String
Dim strEndVal As String
Dim CharPos

strUserValue = Me.Text0

CharPos = InStr(1, strUserValue, " Of ", vbBinaryCompare)
If CharPos > 0 Then
strStartVal = Left(strUserValue, InStr(1, strUserValue, " Of ") - 1)
strEndVal = Right(strUserValue, Len(strUserValue) - (InStr(1,
strUserValue, " Of ") + 3))
strNewVal = strStartVal & " of " & strEndVal
Me.Text0 = strNewVal
End If

Becareful of word wraping in the code above.

Be sure to change the "Text0" to the name of your textbox control.
 
Back
Top