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.
Published: Sunday, September 27, 1998

Capitalizing each Word in a Sentence using ASP


The time may arise that you want an Active Server Pages algorithm to capitalize each letter of a word in a sentence or paragraph. Well, here is the code to do just that, from Microsoft's Support (http://www.microsoft.com/support). Happy Programming!

Function Capitalize(str) 'This function capitalizes each of the words in a sentence. Dim t t = str If t <> "" Then t = UCase(Mid(t, 1, 1)) & Right(t, Len(t) - 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. t = Mid(t, 1, i) & UCase(Mid(t, i + 2, 1)) & Mid(t, i+3, Len(t)) End If If Mid(t, i, 1) = " " Then ' Capitalize words preceded by a space: t = Mid(t, 1, i) & UCase(Mid(t, i + 1, 1)) & Mid(t, i+2, Len(t)) End If Next End If Capitalize = t End Function


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

- continued -