Ask Experts Questions for FREE Help !
Ask
    lamlamlamiaaa's Avatar
    lamlamlamiaaa Posts: 28, Reputation: 2
    New Member
     
    #1

    Feb 13, 2012, 04:23 PM
    Sentence Generator using Array
    I want to create a random sentence generator. The user will enter 20 random words in a textbox, one at a time. And then with those 20 words, a label will pop up with 7 of the 20 words. The sentence doesn't have to make sense.

    Help!
    Rodcane's Avatar
    Rodcane Posts: 2, Reputation: 1
    New Member
     
    #2

    Jun 7, 2014, 10:33 AM
    This may not be exactly what you're looking for but it works.
    There are 4 components placed on the form:
    * Label1. Caption = "Enter a word. Press enter key"
    * Text1.Text Used to accept entries.
    * List1.List Used to store entries
    * Quit.Click Used to exit program

    Dim Digit(20), Swan, Collect$
    Private Sub Quit_Click()
    End
    End Sub
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then KeyAscii = 0
    For Cake = 1 To 20
    If Trim$(Text1.Text) <> "" And List1.ListCount < 21 Then
    List1.AddItem Trim$(Text1.Text): Text1.Text = ""
    Text1.SetFocus
    End If
    Next Cake
    If List1.ListCount = 20 Then
    For Cycle = 1 To 20
    LUNAR:
    Picky = Int(20 * Rnd) + 1
    Collect$ = Collect$ & List1.List(Picky) & vbCrLf
    For Recheck = 1 To 20
    If Picky = Digit(Recheck) Then GoTo LUNAR
    Next Recheck: Digit(Cycle) = Picky
    Swan = Swan + 1
    If Swan = 7 Then GoTo RESULTS
    Next Cycle
    RESULTS:
    Message$ = "Randomly selected 7 words " & vbCrLf & vbCrLf & Collect$
    MsgBox Message$, vbInformation, " Randomly Selected 7 Of Your Words ": Collect$ = "": Swan = 0
    End If
    End Sub

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

How I can change english sentence to bengali sentence for free? [ 1 Answers ]

The day I saw u last time you were slim but now...

If you flatten a probation sentence in jail do I owe fees on that probation sentence? [ 1 Answers ]

Do I owe fees for a probation sentence if I served the time to flatten the probation sentence if I have to come out on a second probation that was ran consecutive to the first?

Generator wiring: new generator gfci breaker tripping [ 2 Answers ]

Generator wiring: I have a new honda generator. I ran 3 wires from the garage to the transfer switch in the house. When I start up and throw in the breaker on the generator, its GFCI trips immediately. It is a long run (125ft) run to the house and I used heavy wires. But I only ran 3 (blk,...

I require for a Power Plus 5000 Generator 1 generator under following specifications: [ 1 Answers ]

I require for a Power Plus 5000 Generator 1 generator under following specifications: 5000 Watts, 120V, 1 Phase, 60 Hz at 3600 RPM, 3720 RPM at no-load. Thank you, Publio

An array [ 1 Answers ]

How many ratings do you wish to enter? 10 Rating #1: 9 Rating #2: 5 Rating #3: 9 Rating #4: 2 Rating #5: 11 Invalid entry, score must be in range of 1 and 10; try again. Rating #5: -1 Invalid entry, score must be in range of 1 and 10; try again. Rating #5: 8


View more questions Search