Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How do I count the number of words in a given text string in vb.net language ????????
Posted

You may try:

VB
Function WordCount(text As String)

  Dim pattern As String = "\b(\w+)\b"
  Dim r As Regex = New Regex(pattern)

  Return r.Matches(text).Count

End Function
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Dec-12 18:39pm    
At least no need to define what a "word" is; a 5.
--SA
CPallini 7-Dec-12 18:41pm    
Thank you, sir.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900