Hello,

How about putting the name/email pairs into a dictionary and then doing a shuffle on an array using the Dictionary.Keys property? Here's an example:

  dim People as Dictionary = new Dictionary

  People.Value("Person 1") = "[EMAIL PROTECTED]"
  People.Value("Person 2") = "[EMAIL PROTECTED]"
  People.Value("Person 3") = "[EMAIL PROTECTED]"
  People.Value("Person 4") = "[EMAIL PROTECTED]"
  People.Value("Person 5") = "[EMAIL PROTECTED]"
  People.Value("Person 6") = "[EMAIL PROTECTED]"

  dim Names() as Variant = People.Keys
  Names.Shuffle()
  msgbox Names(0)
  msgbox People.Key(0)

Then you can access the email corresponding to the name like this:

  For Each CurrentName as string in Names
    msgbox CurrentName + " = " + People.Value(CurrentName)
  Next

Thanks,
Navdeep Bains
Bains Software

On Jul 8, 2006, at 10:01 AM, 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>



_______________________________________________
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>

Reply via email to