Hello gud pple of the forum,
How do i use asp to retrieve the first two hundred words from a field in a database.
Cheers
How do i use asp to retrieve the first two hundred words from a field in a database.
Cheers
function countWords(varString, varWords)
'Start by trimming leading/trailing spaces
strField = trim(varString)
'Trim 2 consecutive spaces down to 1
Do While InStr(1, strField, " ")
strField = Replace(strField, " ", " ")
Loop
Dim arrWords
'split the string by spaces, this will get you the total count of the words
arrWords = split(strField, " ")
numWords = UBound(arrWords) + 1
'if the total number of words is more than you want, get the # of words you want.
if varWords < numWords then
strField = ""
for i = 0 to varWords-1
strField = strField & " " & arrWords(i)
next
end if
countWords = strField
end function
response.Write(countWords(field_to_use,200)) 'indicate which field you want to cut down and the number of words you want it limited to.