VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Count words in a String

by Fabian Holzer (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Sat 23rd December 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Count words in a String

Rate Count words in a String




'------------------------------------------------------
'Author:  Fabian Holzer ([email protected])
'Example: iWordsIn = CountWordsIn("Hallo Welt")
'------------------------------------------------------

Dim i As Integer

For i = 1 To Len(sText)
If Mid$(sText, i, 1) = " " Then
    CountWordsIn = CountWordsIn + 1
End If
Next


If sText = "" Then
    CountWordsIn = 0
Else
    CountWordsIn = CountWordsIn + 1
End If

End Function

Download this snippet    Add to My Saved Code

Count words in a String Comments

No comments have been posted about Count words in a String. Why not be the first to post a comment about Count words in a String.

Post your comment

Subject:
Message:
0/1000 characters