View Single Post
  #3 (permalink)  
Old 10-12-2008, 3:31 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

Quote:
Originally Posted by JohnH View Post
Same concept, almost same code:
Code:
Private r As New Random
Private Function RandomizeWords(ByVal text As String) As String
    Dim words As New List(Of String)(text.Split(" "c))
    Dim newwords As New List(Of String)
    For Each word As String In words
        newwords.Insert(r.Next(0, newwords.Count + 1), word)
    Next
    Return String.Join(" ", newwords.ToArray)
End Function
For example take 500 random picks from that "words" variable in example, remove the picked item as you go.

Thanks John!
Im stuck agian tho, here are the basics on how i'm trying to implement this code.

User opens a .txt file and the contents are sent to global variable "content1". Next the user enters in how many randomized words he wants in textbox "totalwords". All the above works with no errors, from here is where i need your help.

Once a numerical number is entered the user clicks "button12" and that button is to run that code you gave me, thus jumbling whats inside variable "content1" and taking out however many words was entered into the variable "totalwords". Once the code you gave me has jumbled up enough words to satisfy the number defined in "totalwords", the jumbled words are to be sent to a global variable named "scrambled1".

And thats it! The code you gave me works perfect, except for some reason i just cant link the "button12" to activate it and put the radomized words (matching the "totalwords" variable) into the global variable "scrambled1". Thanks!
Reply With Quote