When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
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


ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article