Hi Matt
The problem is that you cannot use variables in a Dim statement. Whatever you put in a Dim statement has to be fixed at compile time, so the compiler can work out how much memory to put aside for storage and other esoteric compiler stuff.
The good news is, there's a way around this:
Code:
'Put all your Dim statements at the top to make the code more readable
Dim intLoop As Integer
'Dim an array with no dimensions. This tells the compiler that we will
'use an array, but we don't know what size it's going to be
Dim istrResponce() As String
'START number of questions
Const csNumQ = InputBox("How many questions do you want" & _
"out of 20?")
If intNumQ > 20 Then
MsgBox ("You chose too many. So we will give you 20 questions")
intNumQ = 20
ElseIf intNumQ < 0 Then
MsgBox ("You can't have a negative number of questions!" & _
"so you obviously don't want to do this!")
intNumQ = 0
End If
'END number of questions
Redim istrResponce(1 to intNumQ)
'START MsgBox's
For intLoop = 1 To intNumQ
strResponce(intLoop) = InputBox(" " & strQs(intLoop) & " " & _
"a: " & strAnsA(intLoop) & " ", "Question " & intLoop)
Next intLoop
'END MsgBox's
One other possible problem is that you seem to have two variables
and
with very similar names - are these supposed to be the same?
Brian Skelton
Braxis Computer Services Ltd.