Count number of words using vb.net

 

In this short tutorial I will show you how can we calculate the number of words in a string .

The string can be a string from inputbox or textbox or any string .

It is  useful because we may need to count the number of words a user may enter.

We have a function in .net called string.split.

Returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array.

Vb.net code

 

 

Dim text As String = InputBox("enter some text")

Dim words() As String = text.Split" charracters")

MsgBox(words.Length &

" charracters")

Thanks Hopes it helps !!!

Remember you can use the same method in other .net languages also.