Hi every body
I have a textbox on my form and i want to know how many words i have writen in it.
the idea >> i thought if i declared ( x as string and x =" ") now x equal one space if i can count how many spaces in the textbox i will know how many words in textbox by adding 1 to result of x .
this is my idea but finally any method will help.
by the way if there are any file *.pdf teatch me functions(trim,len.....) i will be thankful.

Rashakil Fol commented: Unnecessary font. -1

Recommended Answers

All 8 Replies

Member Avatar for iamthwee

Yes, try writing your idea on paper. You would be using looking for spaces, but not just single spaces because words can be separated by more than one space.

Also watch out for tabs etc.

Yes, try writing your idea on paper. You would be using looking for spaces, but not just single spaces because words can be separated by more than one space.

Also watch out for tabs etc.

:D

Hi every body
I have a textbox on my form and i want to know how many words i have writen in it.
the idea >> i thought if i declared ( x as string and x =" ") now x equal one space if i can count how many spaces in the textbox i will know how many words in textbox by adding 1 to result of x .
this is my idea but finally any method will help.
by the way if there are any file *.pdf teatch me functions(trim,len.....) i will be thankful.

why dont you try using textbox1.text.length ?

commented: Won't work... -2

first thanks for all, about (textbox1.text.lenght) this method will count litters not words and iam looking for count of word
thanks again

Member Avatar for iamthwee

Maybe he didn't read the entire thing the answer is there.

Try this:

Dim x As Integer = System.Text.RegularExpressions.Regex.Matches(TextBox1.Text, "\w+").Count()

commented: Another good alternative. +9
commented: You are really good in when it comes to search a code +2

iam sorry (iamthwee) realy i didnot attention about the entire thing,
and thanks (waynespangeler) ur code fantastic
thanks again for all

commented: This font again... -2

Not my code found it sometime ago looking for same thing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.