Count words in string ?

Results 1 to 3 of 3

Thread: Count words in string ?

  1. #1
    Patrik Guest

    Default Count words in string ?

    Is there any easy way to get the number of words in a string ?<BR>Or do I have to make some kind of a loop to count´em ?

  2. #2
    Join Date
    Dec 1969

    Default RE: Count words in string ?

    &#060;%<BR>Function getWordCount(StringToCountWord)<BR>Dim CurPos,PrevPos<BR>Dim WordCount<BR> If Len(Trim(StringToCountWord))&#062;0 Then<BR> PrevPos=1<BR> CurPos=Instr(1,StringToCountWord," ")<BR> Do While CurPos&#062;0<BR> WordCount=WordCount+1<BR> PrevPos=CurPos<BR> CurPos=Instr(CurPos+1,StringToCountWord," ")<BR> Loop<BR> If PrevPos&#062;0 Then WordCount=WordCount+1<BR> End If<BR> getWordCount=WordCount<BR>End Function<BR><BR>Response.Write "(a b c): " & getWordCount("a b c")<BR>Response.Write "(a b): " & getWordCount("a b")<BR>Response.Write "(a): " & getWordCount("a")<BR><BR>%&#062;

  3. #3
    Patrik Guest

    Default RE: Count words in string ?

    WOW !! Thanks a lot<BR>Just copy N paste , alright that&#039;s what I call helpin<BR><BR>TNX again :)

Posting Permissions

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