whats the most popular word?

VBnetster

Active member
Joined
Feb 15, 2008
Messages
32
Programming Experience
Beginner
hi,

been trying all day to make a function to find the most popular word in a string. so say if i had a string "lala xxx lalala xxx la xxx la" then "xxx" would be the popular word. I thought i figured it out once but i fooled myself and im ashamed to post it lol.:(

can i have some help with this?

thx

and i know this has allot to do with arrays, i just made a mess.
 
Dictionary is a typed Hashtable. Try using a hashtable; it'll work but you'll have to do a lot of casting.

Dictionary(Of String, Integer) <-- thats the good bit: you state youre using strings for the keys and ints for the values

myDict("myKey") += 1 'ok
myHashTable("myKey") += 1 'error: Object has no overload for +=
myHashTable("myKey") = DirectCast(myHashTable("myKey"), Int32) + 1 'yawn

Alternately, if you want to turn off Option Strict and Option Explicit and be jsut another regular (i.e. not very skilled) VB programmer, youy might not need to cast.

Good to know, thanks for answering my question thoroughly. :)
 
Back
Top