adn03001's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
6 (0.02 per day)
Joined:
26-June 12
Profile Views:
1,041
Last Active:
User is offline Jul 01 2012 12:27 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   adn03001 has not set their status

Posts I've Made

  1. In Topic: 10 different random sentences generating by using arrays

    Posted 1 Jul 2012

    It is now finally working. Many many thanks to all of you.
  2. In Topic: 10 different random sentences generating by using arrays

    Posted 30 Jun 2012

    Hello,

    Thank you a million for your help. However I did do my work and it is finally outputting. But now the only problem is, it is outputting 2 sentences in one line and it seems like an infinite loop where I only want the random sentences to show upto 10 times instead of forever.

    I already attached it. But here is my code as follows:

    Public Class frmRandomSentences
    
        '5 major array Declarations and initializing the string values for each below:
        Dim strNouns() As String = {"dog", "bear", "Adnan", "dude", "bird", "baby", "person", "boy"}
        Dim strAdjectives() As String = {"darn", "giant", "good", "bad", "angry", "scary", "magnificient", "interesting"}
        Dim strVerbs() As String = {"fell", "walked", "lived", "went", "came", "busted", "hustled", "sneaked"}
        Dim strPrepositions() As String = {"through", "around", "behind", "near", "over", "below", "beneath", "above"}
        Dim strArticles() As String = {"my", "the", "any", "a", "this", "that", "his", "her"}
        'The counter or the index tracker.
        Dim intCount As Integer = 0
    
    
    
        Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
            'Clears the list box.
            lstRandomSentences.Items.Clear()
        End Sub
    
        Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
            'Ends the whole application.
            Me.Close()
        End Sub
    
        Private Sub btnNextSentence_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNextSentence.Click
    
    
            Dim randomValue As New Random 'Creating a random variable.
            Dim intCount As Integer 'Counter loop or index tracker.
            Dim intAccumulate As Integer = 0 'Accumulator. Not sure if needed.
            Dim index As Integer 'Inner indexes.
            Dim wordsSelection As String = "" 'Holds the sentences
    
            'Create ten new random sentences.
            For intCount = 1 To 10
                Dim rndSentence As String = " "
    
                'The following order sentences:
                '1) Articles
                index = randomValue.Next(0, strArticles.Length)
                rndSentence &= strArticles(intAccumulate) & " "
    
                '2) Adjectives
                index = randomValue.Next(0, strAdjectives.Length)
                rndSentence &= strAdjectives(index) & " "
    
                '3) Nouns
                index = randomValue.Next(0, strNouns.Length)
                rndSentence &= strNouns(index) & " "
    
                '4) Verbs
                index = randomValue.Next(0, strVerbs.Length)
                rndSentence &= strVerbs(index) & " "
    
                '5) Prepositions
                index = randomValue.Next(0, strPrepositions.Length)
                rndSentence &= strPrepositions(index) & " "
    
                '6) Articles
                index = randomValue.Next(0, strArticles.Length)
                rndSentence &= strArticles(index) & " "
    
                '7) Adjectives
                index = randomValue.Next(0, strAdjectives.Length)
                rndSentence &= strAdjectives(index) & " "
    
                '8) Nouns
                index = randomValue.Next(0, strNouns.Length)
                rndSentence &= strNouns(index) & " "
    
                wordsSelection &= rndSentence
    
            Next
    
            lstRandomSentences.Items.Add(wordsSelection)
    
        End Sub
    End Class
    
  3. In Topic: 10 different random sentences generating by using arrays

    Posted 30 Jun 2012

    'Here is what I am having trouble:
    
    Private Function GenerateRandomSentence() As String 'returns a string
    
    Dim MyRandomObject as *what goes here?* Random() 'instance the object
    
        Dim Sentence As String
    
        'Got your declarations here
        Dim strNouns() As String = {"dog", "bear", "Adnan", "dude", "bird", "baby", "person", "boy"}
        Dim strAdjectives() As String = {"darn", "giant", "good", "bad", "angry", "scary", "magnificent", "interesting"}
        Dim strVerbs() As String = {"fell", "walked", "lived", "went", "came", "busted", "hustled", "sneaked"}
        Dim strPrepositions() As String = {"through", "around", "behind", "near", "over", "below", "beneath", "above"}
        Dim strArticles() As String = {"my", "the", "any", "a", "this", "that", "his", "her"}
    
    Sentence &= 'What can you concatenate to this string? 'Hint: all arrays index begin at 0 so use the random.next method. strnouns(random.next(0,7)) voila you've just randomly selected an item in strnouns array. Finish it. :P/>
        'I need to put the codes for the 5 arrays (strNouns,strAdjectives,strVerbs,strPrepositions,strArticles) so they can be produced in the following order:
        ''<article> space <adjective> space <noun> space <verb> space <preposition> space <article> space <adjective> space <noun>
    
    
        Return Sentence
    
    End Function
    
    Private Sub btnNextSentence.Click(Byval sender as Object, Byval e as System.eventargs) handles Button1.Click
    
        Dim G As String = GenerateRandomSentence()
    
    MyListBox.Items.add(????) 'what string should you add here?
        'I should be adding the 5 random arrays in the following order like this:
        '<article> space <adjective> space <noun> space <verb> space <preposition> space <article> space <adjective> space <noun>
    
    End Sub
    




    View Posttrevster344, on 30 June 2012 - 07:01 AM, said:

    Follow this code, and fill in the blanks. ;)

    Private Function GenerateRandomSentence() As String 'returns a string
    
    Dim MyRandomObject as *what goes here?* Random() 'instance the object
    Dim Sentence as String
    
    'Got your declarations here
    Dim strNouns() As String = {"dog", "bear", "Adnan", "dude", "bird", "baby", "person", "boy"} 
    Dim strAdjectives() As String = {"darn", "giant", "good", "bad", "angry", "scary", "magnificent", "interesting"}
    Dim strVerbs() As String = {"fell", "walked", "lived", "went", "came", "busted", "hustled", "sneaked"}
    Dim strPrepositions() As String = {"through", "around", "behind", "near", "over", "below", "beneath", "above"}
    Dim strArticles() As String = {"my", "the", "any", "a", "this", "that", "his", "her"}
    
    Sentence &= 'What can you concatenate to this string? 'Hint: all arrays index begin at 0 so use the random.next method. strnouns(random.next(0,7)) voila you've just randomly selected an item in strnouns array. Finish it. :P/>
    
    return Sentence
    End Function
    
    
    Private Sub Button1.Click(Byval sender as Object, Byval e as System.eventargs) handles Button1.Click
    Dim G as String = GenerateRandomSentence()
    
    MyListBox.Items.add(????) 'what string should you add here? :P/>
    End Sub
    
    
  4. In Topic: 10 different random sentences generating by using arrays

    Posted 30 Jun 2012

    Yes I did checked out that random class link. I could not find the examples of adding the random arrays to the list box.
  5. In Topic: 10 different random sentences generating by using arrays

    Posted 29 Jun 2012

    Thanks for your quick reply. But the problem I am having is creating the codes for outputting random sentences in the list box. Here is my whole codes: (I know I definitely have to use For..Next Loops for it).

    Public Class frmRandomSentences
    
        '5 major array Declarations and initializing the string values for each below:
        Dim strNouns() As String = {"dog", "bear", "Adnan", "dude", "bird", "baby", "person", "boy"}
        Dim strAdjectives() As String = {"darn", "giant", "good", "bad", "angry", "scary", "magnificient", "interesting"}
        Dim strVerbs() As String = {"fell", "walked", "lived", "went", "came", "busted", "hustled", "sneaked"}
        Dim strPrepositions() As String = {"through", "around", "behind", "near", "over", "below", "beneath", "above"}
        Dim strArticles() As String = {"my", "the", "any", "a", "this", "that", "his", "her"}
    
    
        Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
            'Clears the list box.
            lstRandomSentences.Items.Clear()
        End Sub
    
        Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
            'Ends the whole application.
            Me.Close()
        End Sub
    
        Private Sub btnNextSentence_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNextSentence.Click
            Dim randomValue As New Random 'Creating a random variable.
            Dim intCount As Integer 'Counter loop.
            Dim intAccumulate As Integer = 0 'Accumulator. Not sure if needed.
    
            'Create ten random sentences.
            For intCount = 1 To 10
                Dim rndSent As String = ""
    
            Next
    
        End Sub
    End Class
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

adn03001 has no profile comments yet. Why not say hello?