Good day! Please help me resolve the problem with regards to Subscript out of Range error I got with my program below: __________________________________________________ _ Function OpenAnswerKey(TypeCode) Set rsAnswerKey = Server.CreateObject("ADODB.Recordset") sqlAnswerKeyText ="SELECT * FROM tblquestionchoices WHERE TestType = " & "'" & TypeCode & "' " & _ "ORDER BY QNum;" rsAnswerKey.Open sqlAnswerKeyText, objConn Do while Not rsAnswerKey.EOF Select Case TypeCode Case "SCI" chrSCIAnswerKey(rsAnswerKey("QNum")) = rsAnswerKey("CorrectAnswer") TotalItemSCI = TotalItemSCI + 1 Case "NUM" chrNUMAnswerKey(rsAnswerKey("QNum")) = rsAnswerKey("CorrectAnswer") TotalItemNUM = TotalItemNUM + 1 End Select rsAnswerKey.MoveNext Loop End Function __________________________________________________ _ Actually, I am developing a test questionnaire (60 item-Science category and 40-item Mathematics category). The code above is part of my program for computing the Total Score (combining the raw score of Math and Science). The error I got states: Error Type: Microsoft VBScript runtime (0x800A0009) Subscript out of range: 'rsAnswerKey(...)' /Technowars/ScoreSummary.asp, line 52 which pertains to the highlighted part in my code above. In addition, please allow me to raise another concern I have. The exam is good for only 30 minutes (for the entire Science and Math exam). How can I include such condition in my program? Considering that the exam for Science (SCIENCEQuestionnaire.asp) is separated from the Math (MATHQuestionnaire.asp) exam. Please help me resolve this problem. Thank you so much for any help you could offer. Best Regards, Alexcher
My guess would be that you aren't passing eough values to the chrSCIAnswerKey function you are calling here: chrSCIAnswerKey(rsAnswerKey("QNum"))