String Function Problem.. need help

Thread: String Function Problem.. need help

1. Senior Member
Join Date
Dec 1969
Posts
112

String Function Problem.. need help

Hi, <BR>I am having a problem with this string function from 4guysfromrolla website.<BR><BR>For some reason it only Captalizes the first letter of the first word and leaves the rest of the string lowercase.<BR><BR>Does anyone know why this is?<BR><BR>Thanks for your help, <BR>hope this is not to tough<BR><BR>Andre<BR><BR><BR><BR>&#060;%<BR>myStr ing=Cstr("This is A String Which should be caPitalized on every Word")<BR><BR><BR>Function Capitalize(str)<BR> <BR> &#039// ------ This function capitalizes each <BR> &#039// ------ of the words in a sentence<BR><BR> Dim i<BR> Dim t<BR> <BR> t=LCase(CStr(str))<BR><BR>if t&#060;&#062; "" and not IsNull(t) then<BR> t=UCase(Mid(t, 1, 1)) & Mid(t, i +2)<BR><BR> For i = 1 to Len(t) -1<BR> if Mid(t, i, 1) = "." then<BR> &#039// ------ Capitalize words/letters preceeded by "."<BR> t=Left(t, i) & UCase(mid(t, i +1, 1)) & Mid(t, i + 2)<BR> end if<BR><BR> if Mid(t, i, 2) = Chr(13) + Chr(10) then<BR> &#039// ------ Captalize words preceeded by carriage return<BR> &#039// ------ plus linefeed combination.<BR> t=Left(t, i) & UCase(Mid(t, i + 2, 1)) & Mid(t, i + 3)<BR> end if<BR><BR> if Mid(t, i, 1) = "" then<BR> &#039// ------ Capitalize words preceeded by a space<BR> t=Left(t, i) & UCase(Mid(t, i + 1, 1)) & Mid(t, i + 2)<BR> end if<BR> Next<BR>end if<BR><BR>Capitalize = t<BR><BR>End Function<BR><BR>response.write Capitalize(myString)<BR><BR>%&#062;

2. Jason Miller Guest

RE: String Function Problem.. need help

www.asp101.com has a capitalization routine that works (for me, anyway).<BR><BR>http://www.asp101.com/samples/pcase.asp

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•