View Single Post
  #2 (permalink)  
Old 10-12-2008, 8:20 AM
JohnH's Avatar
JohnH JohnH is offline
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 36
Posts: 8,138
Reputation: 876
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

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
Quote:
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!
For example take 500 random picks from that "words" variable in example, remove the picked item as you go.
__________________
See this thread about how to use forum markup codes for code blocks etc (present the problem/post properly )
Some useful links: Learning videoes, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ


DR. WEIR: Download it to a non-networked, firewalled computer.
TECHNICIAN: Yes, ma'am.
Reply With Quote