Article ID: 109220
Article Last Modified on 6/29/2004
Sub Text1_LostFocus ()
Dim t As String
t = Text1.Text ' Put contents of text box
' into a string variable.
If t <> "" Then
Mid$(t, 1, 1) = UCase$(Mid$(t, 1, 1))
For i = 1 To Len(t) - 1
If Mid$(t, i, 2) = Chr$(13) + Chr$(10) Then
' Capitalize words preceded by carriage return plus
' linefeed combination. This only applies when the
' text box's MultiLine property is set to True:
Mid$(t, i + 2, 1) = UCase$(Mid$(t, i + 2, 1))
End If
If Mid$(t, i, 1) = " " Then
' Capitalize words preceded by a space:
Mid$(t, i + 1, 1) = UCase$(Mid$(t, i + 1, 1))
End If
Next
Text1.Text = t
End If
End Sub
Keywords: kbhowto kbprogramming KB109220