Access/VBA Library

WordCount

Returns the number of space delimited words in a string.

Syntax

WordCount( aString )
Parameters
Name Type Description
aString String Required. The input string.
Return value

Long : The number of space delimited words.

Code
Public Function WordCount(aString As String) As Long
    Dim words: words = Tokenizer(aString, " ")
    If UBound(words) = -1 Then
        WordCount = 0
    Else
        WordCount = UBound(words) - LBound(words) + 1
    End If
End Function

Stringtag:String