Or, do this. Dim an array of Integer for the same number of elements
(100) that you created the Name() and Email() arrays for. Then:
Dim i As Integer
Dim Index As Integer // This indexes the 'real' name or email.
Dim myIndexArray(100) As Integer
Dim Name(100) As String
Dim Email(100) As String
// Stuff to load up the 'Name' and 'Email' arrays...
DoLoadStuff()
// Load up the index array with each possibility.
For i = 0 To UBound(Name) - 1
myIndexArray(i) = i
Next
// This puts each possible index into the 'index' array. Now:
myIndexArray.Shuffle()
// to randomize. Now, instead of walking (iterating) through the Name
or Email arrays, walk through the
// 'myIndexArray()' array, like so:
For i = 0 To UBound(myIndexArray) - 1
Index = myIndexArray(i)
// Do something with Name(Index) and Email(Index)
ProcessNamesAndEmails(Name, Email, Index)
Next
HTH!
BTW: This code example assumes you load Name() and Email() with 100
elements from 0..99. RB actually gives you 101 elements from 0..100, so
if you load element 100, or are treating the array as a 1-based array,
change the iteration loop(s) accordingly!!
On Jul 8, 2006, at 12:01 PM, Stephen Dodd wrote:
Does anyone know a reasonable method to shuffle paired data?
For instance if I have 2 arrays:
dim Name(100) as string
dim Email(100) as string
I can't use name.shuffle and email.shuffle because they will no longer
match.
If I use:
dim NameAndEmail(100, 1) as String
...
// populate
// NameAndEmail(x, 0) = Name
// NameAndEmail(x, 1) = Email
...
then
NameAndEmail.Shuffle
It appears to mix the dimensions together. That is email will appear
in the name dimension randomly.
Or is this write a shuffle routine from scratch case?
Cheers!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
William H Squires Jr
4400 Horizon Hill #4006
San Antonio, TX 78229
[EMAIL PROTECTED] <- remove the .nospam
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>