I have a program that reads in a .txt datafile into a structure of
property name string
property o variant
property r variant

I can read the 105 row file nicely using an array like myArray(), by typing in a number and getting the results:Example type in 9, myArray(9).name

I have a sample program that uses the shuffle command and I read that into an array:
aTest =Array(0,1,2,3,4,5)

The program I’m using is able to shuffle the numbers and values without repeats, which I like.

Right now, I read the datafile and store the lines into: myArray with the unshuffled numbers.

I would like to know this:

Is it possible to read the datafile, shuffle or randomize the numbers of the array and then I want to use the newly shuffled numbers in my new array list.

If so, how would I do that?

Thanks for your help,

Shuffle works on arrays of any data type.
After you read the data into myArray, just call


Then myArray(9).name will not be the one it was after you read from the file

What Jeff said, although I’d change that to, “myArray(9) probably will not be the one it was…” There is no telling after the shuffle.

Or are you looking for something like a “ShuffleWith” method where an array is shuffled but keeps one or more other arrays in sync? If so, create syncArray1, syncArray2, …, then create indexArray() As Integer that holds the values 0 to syncArray1.Ubound. Then do something like this:

indexArray.SortWith syncArray1, syncArray2, …

Thanks for the help. I went to my program and went to the area right after I read the datafile into myArray. I put in the command: myArray.shuffle

This works great. every time I run the program now, it randomizes the numbers so it it never the same.

Thanks again,