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. Neil Popham Guest

## RE: String Function Problem... need help

i use the following<BR><BR>&#060;%<BR>Function PCase(strText)<BR> Dim strWhitespace, boolCapitalise, intCharacter, strCharacter<BR> strWhitespace = " " & vbCr & vbLf & vbCrLf & "&#039"<BR> strText = LCase(strText)<BR> boolCapitalise = True<BR> For intCharacter = 1 to Len(strText)<BR> strCharacter = Mid(strText, intCharacter, 1)<BR> If boolCapitalise = True Then strCharacter = UCase(strCharacter)<BR> PCase = PCase + strCharacter<BR> If InStr(strWhitespace, strCharacter) Then boolCapitalise = True Else boolCapitalise = False<BR> Next<BR>End Function<BR>%&#062;<BR><BR>which i kinda ripped from a posting a while back

#### Posting Permissions

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