faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 19 people (89%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

Is there a shortcut method for capitalizing the first letter of a word?

Jul 23rd, 2000 00:30
unknown unknown, ASPfreeforall, Phil Smith, Jamie Dearnley


You mean like, UCase(Left(TheInput, 1)) ?
-----------
This little gem will cap the first letter of every word.
"this is a great movie!"
becomes
"This Is A Great Movie!"
<%
' http://www.ultimateasp.com/free/fs.asp
        Function ConvertCap(txt)
                tmp = Split(txt, " ")
                For Each Item In tmp
                        ConvertCap = ConvertCap & UCase(Left(Item, 1)) & 
LCase(Right(Item, 
Len(Item) - 1)) & " "
                Next
                ConvertCap = Left(ConvertCap, Len(ConvertCap) - 1)
        End Function
        test = "this is a great movie!"
        result = ConvertCap(test)
        Response.Write result
%>
--------------
you can use stylesheets to capitalise, but for it to work all the text
must be lower case:
        style='text-transform: capitalize;'



© 1999-2004 Synop Pty Ltd