Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
I want to write a program that calculates the number of words in a particular word in a particular text string
Posted 8-Dec-12 9:08am
Comments
AnkitGoel.com at 10-Dec-12 0:08am
   
do you want to calculate number or occurances of a word in a string?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Count words include space
dim count_ as double = textbox1.text.lenght 
 
Or
 
dim count_ as double = len(textbox1.text)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Not sure what you mean by, "the number of words in a particular word".
 
If you mean you want to count words in a string then here's a starting point for you (check the exact syntax). It assumes a single space between each word.
 
dim words as string() = sentence.split(" ")
dim wordCount as integer = words.length
 
Look at the string.replace() method for a simple way of removing multiple spaces from the input. Then look at regex for a more sophisticated way of removing multiple occurrences of characters/strings.
 
If that isn't what you mean by your question please give an example of what you're trying to do.
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100