Length of String in words vs. characters?

E

Ed

I have used Len(strVariable) to get the length of my text string in
characters. Can I also get the length in "words", or get a count of how
many words are contained in that string?

Thanks for all your help.
Ed
 
J

Jonathan West

Hi Ed,

Yes, you can, but furst you need to define what you mean by a "word". For
instance is "apple-pie" one word or two?

If you want to take the simplest case of words being separated by spaces,
then the following line of code will do the trick

numWords = UBound(Split(stringWithWords, " ")) + 1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top