To read the article online, visit http://www.4GuysFromRolla.com/webtech/tips/t102599-2.shtml

User Tip: Capitalizing Each Word In A Sentence

From John H.:

Here is a function that will capitalize each word in a sentence.

 ``` Function Capitalize(str) 'This function capitalizes each of the words in a sentence. Dim i Dim t t = LCase(CStr(str)) If t <> "" And Not IsNull(t) Then t = UCase(Mid(t, 1, 1)) & Mid(t, i + 2) For i = 1 To Len(t) - 1 If Mid(t, i, 1) = "." Then ' Capitalize words/letters preceded by "." t = Left(t, i) & UCase(Mid(t, i + 1, 1)) & Mid(t, i + 2) End If If Mid(t, i, 2) = Chr(13) + Chr(10) Then ' Capitalize words preceded by carriage return plus ' linefeed combination. t = Left(t, i) & UCase(Mid(t, i + 2, 1)) & Mid(t, i + 3) End If If Mid(t, i, 1) = " " Then ' Capitalize words preceded by a space: t = Left(t, i) & UCase(Mid(t, i + 1, 1)) & Mid(t, i + 2) End If Next End If Capitalize = t End Function ```

 Article Information Article Title: User Tip: Capitalizing Each Word In A Sentence Article Author: Scott Mitchell Article URL: http://www.4GuysFromRolla.com/webtech/tips/t102599-2.shtml