Click to See Complete Forum and Search --> : New Multi-Dimensional Array Post


Nicodemas
04-01-2003, 07:34 AM
strangely, this posted in my old post, so I need to move it to a new one, seeing as it is different from the old.

I've created a script that populates an array (arrQuestion) to six dimensions from a database call.
The first dimension is a control number
2nd: a string value (the questions)
3rd - 6th: multiple choice answers for the question.

What I'm looking to do is take these values as they are loaded, and put them in random indexes (indicies?) in the array.
Here is the code section that handles the process, but its not very random. I've noted the problematic piece of code, and I wonder how I could set the iTemp variable to the entire dimension so that I can transfer all the information to the new array index. Assume for the comments below that it is the first time the loop is executing.

For objCounter = 1 to intTotalQs
arrQuestion(objCounter, 0) = RS("QuestionID") 'Set object x,0 = Question ID
arrQuestion(objCounter, 1) = RS("Question") 'Set object x,1 = the Question
arrQuestion(objCounter, 2) = RS("Answer1") 'Set object x,2 = RS("Answer1")
arrQuestion(objCounter, 3) = RS("Answer2") 'Set object x,3 = RS("Answer2")
arrQuestion(objCounter, 4) = RS("Answer3") 'Set object x,4 = RS("Answer3")
arrQuestion(objCounter, 5) = RS("Answer4") 'Set object x,5 = RS("Answer4")
iRnd = Int(Rnd * intTotalQs) 'Set iRnd = integer between 1 and 4
iTemp = arrQuestion(objCounter) 'Set iTemp = arrQuestion(1) which doesn't work
arrQuestion(objCounter) = arrQuestion(iRnd) 'Set arrQuestion(1) = arrQuestion(random number tween 1 and 45)
arrQuestion(iRnd) =iTemp 'Set arrQuestion(iRnd) = iTemp
RS.MoveNext
Next

Nicodemas
04-01-2003, 08:20 AM
Ahh, iso! If you want to, Mr. Clark, you can nuke the old topic. I've gotten very far away from it.

Any thoughts on the subject while you're at it?

Nicodemas
04-02-2003, 09:16 AM
solution found!

After a week of just toiling with it, I've gotten this to work. have at it!