Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Procedure question 1

Status
Not open for further replies.

protectorfeelgood

Technical User
Nov 10, 2003
5
NO
I'm a total newbie in VBScript - and I need some help.

I need to make a procedure that creates a MsgBox stating the number of words in a given sentence.
It should exclude the spaces in the sentence when doing the count.

Ex. "This is a test" should output "4"

Thankful for any help on this.
 
Hello prot...,
Code:
sTest="This is a test string."
sTest2="This is a test string with sometimes more than one space    as the delimiter of words."
msgbox ubound(split(sTest," "))
msgbox ubound(split(sTest2," "))
In the sTest2 case, you have to do something more. It is also for other normally encountered cases for a normal sentence. sTest2 is just as an example to call for your attention.

regards - tsuji
 
erratum

Of course, add 1 to the zero based ubound() output.

-tsuji
 
Thanks tsuji - you saved my day.
Only have to figure out how I add 1 to the Ubound output - I'm still a newbie... :)
 
Hello again prot...,

I mean simply:
Code:
msgbox ubound(split(sTest," "))+1
msgbox ubound(split(sTest2," "))+1
Care to read some foundation material to get a start on vbs. It is fun but can at times mess up the system if you do not know what you are doing. Thanks for the feedback and good luck.

regards - tsuji
 
Thanks once again - i figured it out by myself. One page further in my book...and there it was :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top