quote:
Originally posted by Etymon
Thank you dayve,
I figured if there was a way that you might know it better than I.
Etymon
I am not completely happy with this but wanted to get something to you before I call it the evening. I will play around with it a bit more tomorrow ... that is unless someone else can tweak it better.
Function CaseIt(fText)
Dim fTextArray, firstCharacter, lengthSentence, capitalizedSentence, sentenceStart, fBreakArray, fBreaks
fText = lcase(fText)
fText = replace(fText, "<br />", " <br /> ")
fTextArray = split(fText, ". ")
For i = lbound(fTextArray) to ubound(fTextArray)
if InStr(fTextArray(i), "<br />") = 0 then
firstCharacter = ucase(left(fTextArray(i),1))
sentenceStart = 2
else
fBreakArray = ubound(split(fText, "<br />"))
fTextArray(i) = Replace(fTextArray(i), "<br />", "")
for j = 1 to fBreakArray
fBreaks = fBreaks + "<br />"
next
firstCharacter = ucase(left(ltrim(fTextArray(i)), 1))
firstCharacter = fBreaks & firstCharacter
sentenceStart = 3 + ((j-2)*2)
end if
lengthSentence = len(fTextArray(i))
capitalizedSentence = firstCharacter & mid(fTextArray(i), sentenceStart, lengthSentence)
CaseIt = CaseIt & capitalizedSentence
if i < ubound(fTextArray) then CaseIt = CaseIt & ". "
Next
End Function
Example:
http://www.burningsoulsforum.com/caseit.asp
PS. Whatever you do, just don't share the code with http://www.thedailywtf.com
BAH!!! I must be tired. I didn't account for question marks and exclamation points. I've also made way too many assumptions on what characters precede a sentence. I didn't account for things like italicize, bolding, etc. More edits <