|
-
Jun 3rd, 2009, 04:50 PM
#1
[RESOLVED] Random Generator for words?
Ok, basically this is a two part question.
1. Is it possible to have vb.net piece together a legitimate word of a specified length, or do I need to have a massive word list, and generate a random number to pick a word from this list?
2. I also need to separate each letter of the word and display an image for each letter, and each letter going to the next based on a timer, and can also repeat on a button click.
Eg: TWO would end up displaying T W O, a few seconds apart from each other.
If you have any questions about what I'm trying to do, look at this website:
http://asl.ms/
It has the javascript equivalent of what I want to accomplish in vb.net
Thanks for any help you offer.
-
Jun 3rd, 2009, 04:57 PM
#2
Re: Random Generator for words?
1. Is it possible to have vb.net piece together a legitimate word of a specified length, or do I need to have a massive word list, and generate a random number to pick a word from this list?
What is a "legitimate" word?
-
Jun 3rd, 2009, 04:58 PM
#3
Re: Random Generator for words?
Ok, legitimate as in its actually in the English language, and not something like:
takiej, which would make no sense, and more something like: Two, Or, As, Together, But, and so on.
-
Jun 3rd, 2009, 04:59 PM
#4
Re: Random Generator for words?
How do you imagine VB would do this without a list of acceptable words?
-
Jun 3rd, 2009, 05:01 PM
#5
Re: Random Generator for words?
Maybe something that could pull words from Microsoft Words dictionary. I have no idea if its possible though.
-
Jun 3rd, 2009, 05:04 PM
#6
Re: Random Generator for words?
Ok, I assumed I'd need to supply a wordlist, but it was worth asking.
Ok, lets say I have my text file, and I load it into an array, now I need to select a random word from that array, and break the word into letters, displaying an image for each letter that lasts for a few seconds, how can I do this?
-
Jun 3rd, 2009, 05:11 PM
#7
Re: Random Generator for words?
By Image do you mean literally in a PictureBox or just in a Label?
Search (the forums or google) for reading text files by line.
-
Jun 3rd, 2009, 05:13 PM
#8
Re: Random Generator for words?
OK I was just pointing out that in a general purpose programming language you're not going to find natural language validation!
Given any string you can find a character at a given position using the Substring function, eg
Code:
for X as integer = 0 to myWord.Length-1
myLetter = myWord.Substring(x,1)
next X
-
Jun 3rd, 2009, 05:14 PM
#9
Re: Random Generator for words?
I literally mean PictureBox, and I already did a search for Reading Txt files line by line into arrays, and got that code.
Basically, once it generates a number, it picks it from the array, and then breaks that specified word apart into single letters, showing an image file (like g.png or y.png) for each letter, lasting for a couple of seconds.
-
Jun 4th, 2009, 07:39 AM
#10
Re: Random Generator for words?
-
Jun 4th, 2009, 08:55 AM
#11
Re: Random Generator for words?
Hi,
You can perhaps use a spellchecker in your application.
Here's an example how to use it.
-
Jun 4th, 2009, 09:26 AM
#12
Re: Random Generator for words?
How about just download a dictionary of words as a text file? put them in a List object and you can select words at random.
"Ok, my response to that is pending a Google search" - Bucky Katt.
"There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
"Before you can 'think outside the box' you need to understand where the box is."
-
Jun 4th, 2009, 11:06 AM
#13
Re: Random Generator for words?
For generating random words, you will need a word list, load it to an array and generate a random index to get a random word.
As for showing the letters as images, you will need the images of all the letters. Load it into a dictionary(of char, image) and using the letter itself as the key, the image as the value. When you have a word, just loop thru each character in the string and pull off the correct image from the dictionary to display in your picturebox.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jun 4th, 2009, 03:57 PM
#14
Re: Random Generator for words?
When you have a word, just loop thru each character in the string and pull off the correct image from the dictionary to display in your picturebox.
Any Easy loop method to do this?
-
Jun 4th, 2009, 04:22 PM
#15
Re: Random Generator for words?
You can do something like this:
Code:
'Declare a dictionary with class scope
Private letterImages As New Dictionary(Of Char, Image)
'=================================================================
'Then in form load or some other approriate event, load the dictionary with letter images
letterImages.Add("a"c, Image.FromFile("path to the image of letter a here"))
letterImages.Add("b"c, Image.FromFile("path to the image of letter b here"))
letterImages.Add("c"c, Image.FromFile("path to the image of letter c here"))
'keep on going to load the dictionary with images of the letters in the alphabet
'
letterImages.Add("Z"c, Image.FromFile("path to the image of letter Z here"))
'================================================================
'When you want to show the images of the letters in a string, loop thru a string and display the images of the letters
Dim s As String = "Hello"
For Each ch As Char In s
'Test to see if there is a coressponding image for this letter
If letterImages.ContainsKey(ch) Then
'If there is, show it
PictureBox1.Image = letterImages(ch)
PictureBox1.Refresh()
'Pause 2 seconds
System.Threading.Thread.Sleep(2000)
End If
Next
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jun 4th, 2009, 06:11 PM
#16
Re: Random Generator for words?
Thank you very much for this stanav! Now that I see what to do, it seems simpler than I thought it would be.
Thank you all for the help!
-
Jun 4th, 2009, 06:29 PM
#17
Fanatic Member
Re: [RESOLVED] Random Generator for words?
Hey, I was looking into stanav's code, but what does the letter "c" (the one after "a") mean in this line of code:
vb.net Code:
letterImages.Add("a"c, Image.FromFile("path to the image of letter a here"))
(I know this thread is resolved, but I didn't know if I should've opened a new thread to post my question..)
Last edited by tassa; Jun 4th, 2009 at 06:32 PM.
-
Jun 4th, 2009, 06:31 PM
#18
Re: [RESOLVED] Random Generator for words?
probably character, like you can use I for integer after a number.
vb.net Code:
Dim x As Integer = 25I ' The I automatically means integer....or so I have been told this.
-
Jun 4th, 2009, 06:48 PM
#19
Fanatic Member
Re: [RESOLVED] Random Generator for words?
In your example "I" would mean Integer or the Dim'ed integer?
-
Jun 4th, 2009, 06:56 PM
#20
Re: [RESOLVED] Random Generator for words?
"I" would mean just Integer. Its automatically telling the compiler that it is an integer, even though it was defined as an integer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|