Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27514

VS 2010 Random sentence generator question

$
0
0
Hello everyone,

I'm trying to create an application that uses random-number generation to create sentences. i have to have 4 arrays, which i think i have done correctly and pull the random words from the 4 arrays in the following order : 1, 2, 3, 4, 1, 2 and concatenate each word to the previous word as its picked. then do that 10 times total from a single button click.

This is what i have so far:
Code:

Private Sub gererateButton_Click(ByVal sender As System.Object,
      ByVal e As System.EventArgs) Handles gererateButton.Click


      Dim RandomObject As New Random()

      For i = 1 To 10

        Dim myRandomArticle1 As String
        Dim myRandomArticle2 As String

        Dim randomArticle(4) As String
        randomArticle(0) = "the"
        randomArticle(1) = "a"
        randomArticle(2) = "one"
        randomArticle(3) = "some"
        randomArticle(4) = "any"

        myRandomArticle1 = randomArticle(RandomObject.Next(4))

        Do
            myRandomArticle2 = randomArticle(RandomObject.Next(4))

        Loop While myRandomArticle2 = myRandomArticle1

      Next

      For j = 1 To 1

        Dim myRandomNoun1 As String
        Dim myRandomNoun2 As String

        Dim randomNoun(4) As String
        randomNoun(0) = "boy"
        randomNoun(1) = "girl"
        randomNoun(2) = "dog"
        randomNoun(3) = "town"
        randomNoun(4) = "car"

        myRandomNoun1 = randomNoun(RandomObject.Next(4))

        Do
            myRandomNoun2 = randomNoun(RandomObject.Next(4))
        Loop While myRandomNoun2 = myRandomNoun1

      Next

      For k = 1 To 1

        Dim randomVerb(4) As String
        randomVerb(0) = "drove"
        randomVerb(1) = "jumped"
        randomVerb(2) = "ran"
        randomVerb(3) = "walked"
        randomVerb(4) = "skipped"

        Dim myRandomVerb As String = randomVerb(RandomObject.Next(4))

      Next

      For l = 1 To 1

        Dim randomPreposition(4) As String
        randomPreposition(0) = "to"
        randomPreposition(1) = "from"
        randomPreposition(2) = "over"
        randomPreposition(3) = "under"
        randomPreposition(4) = "on"

        Dim myRandomPreposition As String = randomPreposition(RandomObject.Next(4))
      Next

but with this i cannot get this into a single sentence of a TextBox yet alone run 10 times in a row. I'm sorry, i'm a noob. can someone please point me in the right direction? really trying to learn vb.net as best i can.

thank you!

Viewing all articles
Browse latest Browse all 27514

Trending Articles