Code:'being as every one has had a guess, my guess is you 'would like to scramble the words around so here it is 'you first split the string into individual words 'you then randomize a collection of the count of the words 'then you redim your zero based myArr to a 1 based array ' 'then you read the array back using the random numbers as the 'order in which the words are recalled from the array. ' 'add a command button and a text box (Command1 and Text1) ' 'for the split function to work you need VB6 and if you don't have it 'do a search or post for it cause there is a function for VB5 written by 'Aaron Young (Least I think that is who posted it.) Option Explicit Private Sub Command1_Click() Dim nTry As Integer Dim nAddCount As Integer Dim bFound As Integer Dim intCre As Integer Dim nDummy As Integer Dim MyCollection As New Collection Dim myString As String Dim myArr As Variant myString = Text1.Text myArr = Split(myString, " ") nAddCount = UBound(myArr) + 1 Randomize Do Until intCre = UBound(myArr) + 1 nTry = Int((nAddCount * Rnd)) + 1 On Error Resume Next nDummy = MyCollection.Item(CStr(nTry)) bFound = (Err = 0) If bFound Then Err.Clear Else MyCollection.Add nTry, CStr(nTry) intCre = intCre + 1 End If Loop Dim myArray() Dim i As Integer Text1.Text = "" ReDim Preserve myArr(1 To nAddCount) For i = 1 To nAddCount ReDim Preserve myArray(i) myArray(i) = MyCollection(i) If i = 1 Then Text1.Text = myArr(myArray(i)) Else Text1.Text = Text1.Text & " " & myArr(myArray(i)) End If Next i End Sub




Reply With Quote