conting repeated words

vb.net , java , cpp , asp.net Malé, Maldives
  • 12 years ago
    count number of times each word repeats in a text box and display in a list box.(list box should display the word and number of time repeated)the same word should not be repeat on the list box.
  • 12 years ago
    hi Viper, Use an array to store each word, from the very first word in the textbox start picking the words, while picking the word compare it with the words stored in the array. And if the word is a repeat then increment it i.e. here I am assumed that your array is a 2 dimensional array(word , increment). Once this is completed, Bind it with your list box. for this add items to the array list like: Canada 10 England 4 Regards, Royal
  • 12 years ago
    Hi, I would be temped to use something like a dictionary or a hashtable. Split the string by the space character and then loop through the array returned adding each word to the dictionary. If an error occurs, then the word already exists, trap that error, and then increment the value in that word entry in the dictionary. I can't remember if you can bind a dictionary to a listbox, something tells me you can, but you can check it out from there. there are plenty of array controls for this type of work. HTH Si

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” - Brian Kernighan