View Single Post
  #1 (permalink)  
Old 10-11-2008, 11:09 PM
matty matty is offline
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Oct 2008
Posts: 5
Reputation: 0
matty is on a distinguished programming path ahead
Default VB Word Jumbler, not scrambler :)

Hello all,

I'm not the best when it comes to this, but i've been banging my head for days and i think its time i try to ask some of the very talented ppl i see on this site a quick question.
I stumbled across this post from about 2 months ago...
Basic Word Jumber

What that post is about is almost exactly what i need...except i dont want the characters in the individual words to be changed, i just need the whole words moved around. For example a text file/box that contains this "Jim Tire Tall2 G'night" would be "jumbled" or rearanged randomly to "Tall2 Jim G'night Tire". So far i have this code done, but it only gives me one word at a time, not all the words all at once.

Code:
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        Dim MyArray() As String = Split(testtxtbox1.Text, " ")
        Dim I As Integer
        Dim Index1 As Integer
        Dim Index2 As Integer
        Dim Temp As String

        For I = 1 To 20
            Index1 = Int(Rnd() * 10)
            Index2 = Int(Rnd() * 10)
            While Index1 = Index2
                Index2 = Int(Rnd() * 10)
            End While
            Temp = MyArray(Index1)
            MyArray(Index1) = MyArray(Index2)
            MyArray(Index2) = Temp
        Next I

        testtxtbox2.Text = Temp


    End Sub
One last thing....lets say there are 1000 words in this text file that i want to "jumble" up - but out of those 1000 words i specify in the program that i want only 500 random words out of that 1000 word file. Any ideas? Thanks in advance everyone!

Matt
Reply With Quote