We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 22,418 times

Related Categories

Proper Capitalization - Proper Capitalization

Proper Capitalization

This code is used to capitalize the first letter of every word in a string passed as an argument.  All you have to do is past the function code near the beginning of your script command and call the function using the command PropCase(String).  Simple as that.

<%
Function PropCase(strTemp)
 Dim intFound
 Dim strTempName

 Do
   strTempName = strTempName & UCase(Left(strTemp, 1))
   strTemp     = Right(strTemp, Len(strTemp) - 1)
   intFound    = InStr(strtemp, " ")
   If intFound <> 0 Then
     strTempName = strTempName & Left(strTemp, intFound)
     strTemp = Right(strTemp, Len(strTemp) - intFound)
   Else
     strTempName = strTempName & strTemp
     Exit Do
   End If
 Loop While intFound <> 0
 Response.Write strTempName
End Function
%>

Comments

  • asp capitalize words

    Posted by floydfix on 16 Sep 2005

    I am fairly new to ASP and so forth,, alot of learning.... been give the code to capitalize words of:

    <%
    Function PropCase(strTemp)
    Dim intFound
    Dim strTempName

    Do
    strTempName = st...

  • Asp Capitalization of words

    Posted by floydfix on 16 Sep 2005

    I am fairly new to ASP and so forth,, alot of learning.... been give the code to capitalize words of:

    <%
    Function PropCase(strTemp)
    Dim intFound
    Dim strTempName

    Do
    strTempName = strT...

  • Could your function be made to work with line feed

    Posted by stratinblue on 02 Feb 2005

    Hi Ken,

    I found your function to proper case a string very useful. Would it be possible for the function to work if there were linefeeds in the string?

    E.G

    mr anyone
    15 anywhere street
    lond...

  • Uppaer case first letter of each word in a string

    Posted by keng on 29 Dec 2004

    An alternative to do a similar thing but which possibly runs a lot faster:
    <%
    Function EIPropCase(EIString)
       ' Developed by Ken Good of Edge Impact Consulting Ltd, www.edgeimpact.co.uk
       ' This fu...

  • Perfect answer

    Posted by JenMarsh79 on 04 Feb 2004

    This did exactly what I needed it to do. I had a list of company names that were all in caps, so I used this little function. Instead of "Response.Write strTempName" I used "PropCase = strTempName". ...