If you want to assume that all words are seperated by a space you can use a function like
Function fCountWords(strIn As String) As Integer Dim varWords As Variant
If InStr(strIn, " ") > 0 Then varWords = Split(strIn, " ") fCountWords = UBound(varWords) - LBound(varWords) + 1 Else fCountWords = 1 End If
End Function
|
in your database (use it in db and not in asp so you don't have to pull all records down)
If you want to be sure to catch double spaces etc. (still not 100% because of Forum Codes a VBA function like
Function WordCount(str As String) As Long
Dim c As String ' Character to examine Dim i As Long ' index into string Dim nw As Long ' number of words counted Dim inword As Boolean ' indicates c is in a word or outside a word
i = 1 Do While i <= Len(str) c = mid$(str, i, 1) If (c = Chr$(32) OR c = Chr$(9)) Then ' c is a "white character" (a non-word character) ' Add other characters if you like: NL chr(10), CR chr(13), etc. inword = False ElseIf Not inword then inword = True nw = nw + 1 End If i = i + 1 Loop
WordCount = nw
End Function
|
may work for you.
Well I don't know why you need that and it sure will cause a lot of overhead depending on the size of your forum but you can use both as a vba function and return the value to an asp page.