Finding how many times the same word appears in a text file? {RESOLVED} THANKS JOACIM
Hello,
I have a .txt file and it loads into a TextBox on my program. Once loaded I need a cmd button to click that will tell me how many times each word that exists in the textbox is.
For example.
Textbox.Text = Hello, My name is Stilekid007, what is your name?
RESULTS WOULD BE:
1 Hello
1 My
2 Name
2 Is
1 Stilekid007
1 What
1 Your
-------
Does anyone know if this can be done in VB 6.0?
Thank you so muc for any replys!
Stilekid007
Last edited by stilekid007; Jun 13th, 2005 at 07:24 PM.
Re: Finding how many times the same word appears in a text file?
Oh yes it does! The oWordCounter is a collection containing CWord objects (called oWord above). This object has two properties, Word and Count, the Count property will be how many times that particular word existed in the text. The CWords collection, called oWordCounter above also has a Count property but that will contain the number of different words that existed in the supplied text.
Re: Finding how many times the same word appears in a text file?
Originally Posted by stilekid007
hmmmmmm It only displays which words are in the sentence. Not how many times each appear.
Joacim,
Nice code, BTW here is my output:
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."