Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Capitalizing First Letter


Message #1 by "Sertial, Sam" <2495XX2@a...> on Mon, 26 Feb 2001 14:22:48 -0500
This Function to	Capitalizing the first letter work for a single name

like "Jack", any ideas on how to Capitalizing the first letter of

two names like "Jack Tran". The first function is:



Function InitCap(sStr)

     InitCap = ucase(left(sStr,1))& lcase(mid(sStr,2))

End Function





the other function(is not working)

Function CapFirstLetter(str)



    Dim tmpValue 

    Dim tmpValue1

    Dim tmpValue2

    

    'assign initial value

    tmpValue = Trim(str)

    

   ' 'validate against empty strings

    If tmpValue = "" Then

        Exit Function

    End If

    

    'parse first letter from string, capitalize it, and re-concatanate with

remainder of string

    tmpValue1 = Mid(tmpValue, 1, 1)

    tmpValue2 = Right(tmpValue, (Len(tmpValue) - 1))

    tmpValue = UCase(tmpValue1) & tmpValue2



    'assign final value

    CapFirstLetter = tmpValue



End Function 



Any ideas please



Message #2 by Shaun Steckley <SSTECKLEY@P...> on Mon, 26 Feb 2001 14:53:50 -0500
Split the input string on the space and the capitalize each word's first

letter and rejoin...  Check for syntax...



words = split(str, " ")



for i = lbound(str) to ubound(str)

	words(i) = InitCap(words(i))

next



formattedString = Join(words, " ")

Message #3 by "Sertial, Sam" <2495XX2@a...> on Mon, 26 Feb 2001 17:48:37 -0500
Tanks Shaun, please review this code because the result is not:

Function InitCap1(sStr)

   dim i

   dim str

   dim str1

   dim str2 

   str1 = UCase(Left(sStr, 1))& LCase(Right(sStr, Len(sStr)-1))

   'InitCap = ucase(left(sStr,1))& lcase(mid(sStr,2))

   str = trim(sStr)

   if str = "" then

     exit function

   end if 

   str2 = split(sStr," ")

   for i = lbound(sStr)to ubound(sStr)

    str(i) = initcap1(str(i))

    next

     

  str = str1 & str2

   str = join (str," ")

   initCap1 = str  

End Function 



-----Original Message-----

From: Shaun Steckley [mailto:SSTECKLEY@P...]

Sent: Monday, February 26, 2001 2:54 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Capitalizing First Letter





Split the input string on the space and the capitalize each word's first

letter and rejoin...  Check for syntax...



words = split(str, " ")



for i = lbound(str) to ubound(str)

	words(i) = InitCap(words(i))

next



formattedString = Join(words, " ")

Message #4 by "TomMallard" <mallard@s...> on Mon, 26 Feb 2001 17:49:11 -0800
You can use style sheets for this with v4 browsers and up...



text-transform:capitalize;



tom mallard

seattle

----- Original Message -----

From: "Sertial, Sam" <2495XX2@a...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Monday, February 26, 2001 2:48 PM

Subject: [asp_web_howto] RE: Capitalizing First Letter





> Tanks Shaun, please review this code because the result is not:

> Function InitCap1(sStr)

>    dim i

>    dim str

>    dim str1

>    dim str2

>    str1 = UCase(Left(sStr, 1))& LCase(Right(sStr, Len(sStr)-1))

>    'InitCap = ucase(left(sStr,1))& lcase(mid(sStr,2))

>    str = trim(sStr)

>    if str = "" then

>      exit function

>    end if

>    str2 = split(sStr," ")

>    for i = lbound(sStr)to ubound(sStr)

>     str(i) = initcap1(str(i))

>     next

>

>   str = str1 & str2

>    str = join (str," ")

>    initCap1 = str

> End Function

>

> -----Original Message-----

> From: Shaun Steckley [mailto:SSTECKLEY@P...]

> Sent: Monday, February 26, 2001 2:54 PM

> To: ASP Web HowTo

> Subject: [asp_web_howto] RE: Capitalizing First Letter

>

>

> Split the input string on the space and the capitalize each word's first

> letter and rejoin...  Check for syntax...

>

> words = split(str, " ")

>

> for i = lbound(str) to ubound(str)

> words(i) = InitCap(words(i))

> next

>

> formattedString = Join(words, " ")

>

Message #5 by "Wally Burfine" <oopconsultant@h...> on Tue, 27 Feb 2001 04:02:47 -0000
Try this:



function InitCap(sStr)

     Dim strS

     Dim iI

     strS = trim(strS)

     strS = ucase(left(strS,1))& lcase(mid(strS,2))

     iI = inStr(strS," ")

     while iI > 0

          ' Uppercase every word

          if iI < len(strS) then

                ' not the last letter

                strS = left(strs,iI) & uCase(mid(strS,iI+1,1)) & _

                            mid(strS,iI+2)

          else

                ' Last letter in string

                strS = left(strs,iI) & uCase(mid(strS,iI+1))

          end IF

          iI = inStr(strS," ")

     wend

     InitCap = strS

end function



Regards,

Wally

>From: "Sertial, Sam" <2495XX2@a...>

>Reply-To: "ASP Web HowTo" <asp_web_howto@p...>

>To: "ASP Web HowTo" <asp_web_howto@p...>

>Subject: [asp_web_howto] Capitalizing First Letter

>Date: Mon, 26 Feb 2001 14:22:48 -0500

>

>This Function to	Capitalizing the first letter work for a single name

>like "Jack", any ideas on how to Capitalizing the first letter of

>two names like "Jack Tran". The first function is:

>

>Function InitCap(sStr)

>      InitCap = ucase(left(sStr,1))& lcase(mid(sStr,2))

>End Function

>

>

>the other function(is not working)

>Function CapFirstLetter(str)

>

>     Dim tmpValue

>     Dim tmpValue1

>     Dim tmpValue2

>

>     'assign initial value

>     tmpValue = Trim(str)

>

>    ' 'validate against empty strings

>     If tmpValue = "" Then

>         Exit Function

>     End If

>

>     'parse first letter from string, capitalize it, and re-concatanate 

>with

>remainder of string

>     tmpValue1 = Mid(tmpValue, 1, 1)

>     tmpValue2 = Right(tmpValue, (Len(tmpValue) - 1))

>     tmpValue = UCase(tmpValue1) & tmpValue2

>

>     'assign final value

>     CapFirstLetter = tmpValue

>

>End Function

>

>Any ideas please

>

>
Message #6 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Tue, 27 Feb 2001 09:59:51 -0000
Function titleCase(sName)

	

	dim a, s



	a = split(sName, " ")



	sName = ""

	

	For each s in a

		sName = sName & UCase(left(s,1))& LCase(Mid(s,2)) & " "

	Next

	

	sName = Left(sName,Len(sName)-1)

	

	titleCase = sName



End function









-----Original Message-----

From: Sertial, Sam [mailto:2495XX2@a...]

Sent: Monday, February 26, 2001 7:23 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Capitalizing First Letter





This Function to	Capitalizing the first letter work for a single name

like "Jack", any ideas on how to Capitalizing the first letter of

two names like "Jack Tran". The first function is:



Function InitCap(sStr)

     InitCap = ucase(left(sStr,1))& lcase(mid(sStr,2))

End Function





the other function(is not working)

Function CapFirstLetter(str)



    Dim tmpValue 

    Dim tmpValue1

    Dim tmpValue2

    

    'assign initial value

    tmpValue = Trim(str)

    

   ' 'validate against empty strings

    If tmpValue = "" Then

        Exit Function

    End If

    

    'parse first letter from string, capitalize it, and re-concatanate with

remainder of string

    tmpValue1 = Mid(tmpValue, 1, 1)

    tmpValue2 = Right(tmpValue, (Len(tmpValue) - 1))

    tmpValue = UCase(tmpValue1) & tmpValue2



    'assign final value

    CapFirstLetter = tmpValue



End Function 



Any ideas please

________________________________________________________________________

Scottish Enterprise Network

http://www.scottish-enterprise.com

Message #7 by "Sertial, Sam" <2495XX2@a...> on Tue, 27 Feb 2001 09:52:31 -0500
Thanks Alex your function is working fine, but if the name was split by " "

or sometime by "-"dash like : hohn-elton or john elton. Is any way to modify

the split(sname)to incluse either

" " or "-".

Thanks



-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]

Sent: Tuesday, February 27, 2001 5:00 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Capitalizing First Letter





Function titleCase(sName)

	

	dim a, s



	a = split(sName, " ")



	sName = ""

	

	For each s in a

		sName = sName & UCase(left(s,1))& LCase(Mid(s,2)) & " "

	Next

	

	sName = Left(sName,Len(sName)-1)

	

	titleCase = sName



End function









-----Original Message-----

From: Sertial, Sam [mailto:2495XX2@a...]

Sent: Monday, February 26, 2001 7:23 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Capitalizing First Letter





This Function to	Capitalizing the first letter work for a single name

like "Jack", any ideas on how to Capitalizing the first letter of

two names like "Jack Tran". The first function is:



Function InitCap(sStr)

     InitCap = ucase(left(sStr,1))& lcase(mid(sStr,2))

End Function





the other function(is not working)

Function CapFirstLetter(str)



    Dim tmpValue 

    Dim tmpValue1

    Dim tmpValue2

    

    'assign initial value

    tmpValue = Trim(str)

    

   ' 'validate against empty strings

    If tmpValue = "" Then

        Exit Function

    End If

    

    'parse first letter from string, capitalize it, and re-concatanate with

remainder of string

    tmpValue1 = Mid(tmpValue, 1, 1)

    tmpValue2 = Right(tmpValue, (Len(tmpValue) - 1))

    tmpValue = UCase(tmpValue1) & tmpValue2



    'assign final value

    CapFirstLetter = tmpValue



End Function 



Any ideas please

Message #8 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Tue, 27 Feb 2001 15:12:21 -0000
unfortunately not... and if there was then you would not know wether to put

a space or a hyphen when rebuilding the name...



before returning sName, have another loop which looks for hyphens and

capitalises the letter following the hyphen (don't set the remaining letters

to lowercase)



-----Original Message-----

From: Sertial, Sam [mailto:2495XX2@a...]

Sent: Tuesday, February 27, 2001 2:53 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Capitalizing First Letter





Thanks Alex your function is working fine, but if the name was split by " "

or sometime by "-"dash like : hohn-elton or john elton. Is any way to modify

the split(sname)to incluse either

" " or "-".

Thanks



-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]

Sent: Tuesday, February 27, 2001 5:00 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Capitalizing First Letter





Function titleCase(sName)

	

	dim a, s



	a = split(sName, " ")



	sName = ""

	

	For each s in a

		sName = sName & UCase(left(s,1))& LCase(Mid(s,2)) & " "

	Next

	

	sName = Left(sName,Len(sName)-1)

	

	titleCase = sName



End function









-----Original Message-----

From: Sertial, Sam [mailto:2495XX2@a...]

Sent: Monday, February 26, 2001 7:23 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Capitalizing First Letter





This Function to	Capitalizing the first letter work for a single name

like "Jack", any ideas on how to Capitalizing the first letter of

two names like "Jack Tran". The first function is:



Function InitCap(sStr)

     InitCap = ucase(left(sStr,1))& lcase(mid(sStr,2))

End Function





the other function(is not working)

Function CapFirstLetter(str)



    Dim tmpValue 

    Dim tmpValue1

    Dim tmpValue2

    

    'assign initial value

    tmpValue = Trim(str)

    

   ' 'validate against empty strings

    If tmpValue = "" Then

        Exit Function

    End If

    

    'parse first letter from string, capitalize it, and re-concatanate with

remainder of string

    tmpValue1 = Mid(tmpValue, 1, 1)

    tmpValue2 = Right(tmpValue, (Len(tmpValue) - 1))

    tmpValue = UCase(tmpValue1) & tmpValue2



    'assign final value

    CapFirstLetter = tmpValue



End Function 



Any ideas please

________________________________________________________________________

Scottish Enterprise Network

http://www.scottish-enterprise.com


  Return to Index