Results 1 to 20 of 20

Thread: [RESOLVED] Random Generator for words?

  1. #1

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Resolved [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.

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    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?

  3. #3

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    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.

  4. #4
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Random Generator for words?

    How do you imagine VB would do this without a list of acceptable words?

  5. #5
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Random Generator for words?

    Maybe something that could pull words from Microsoft Words dictionary. I have no idea if its possible though.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  6. #6

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    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?

  7. #7
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    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.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  8. #8
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    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

  9. #9

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    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.

  10. #10

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Random Generator for words?

    Any help?

  11. #11
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Random Generator for words?

    Hi,

    You can perhaps use a spellchecker in your application.
    Here's an example how to use it.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  12. #12
    PowerPoster SJWhiteley's Avatar
    Join Date
    Feb 2009
    Location
    South of the Mason-Dixon Line
    Posts
    2,256

    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."

  13. #13
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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 -

  14. #14

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    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?

  15. #15
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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 -

  16. #16

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    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!

  17. #17
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    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:
    1. 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.
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  18. #18

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: [RESOLVED] Random Generator for words?

    probably character, like you can use I for integer after a number.
    vb.net Code:
    1. Dim x As Integer = 25I ' The I automatically means integer....or so I have been told this.

  19. #19
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Re: [RESOLVED] Random Generator for words?

    In your example "I" would mean Integer or the Dim'ed integer?
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  20. #20

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    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
  •  



Click Here to Expand Forum to Full Width