Subscript error 9

sohiab

New Member
Joined
Feb 19, 2008
Messages
5
I get a subscript error 9 when using my questionaire interface. I've highlighted where the error occurs. Anyone have any ideas?

Option Explicit
Dim m_Prev_QID() As Integer
Dim m_Next_QID() As Integer
Dim m_QID As Integer
Dim m_ItemNo As Integer
Dim m_Question As String
Dim m_Response As String
Dim m_Validation As String
Dim m_PCSOutput As String
Dim m_TotalUniqueQuestions As Integer
Private Sub cmbOptions_Change()

'Get the Option Item Number from the list
If cmbOptions.ListIndex <> -1 Then
m_ItemNo = cmbOptions.ListIndex + 1
m_Response = cmbOptions.Value
cmdNext.Enabled = True
End If

End Sub
Private Sub cmdEnd_Click()

Unload Me

End Sub
Private Sub cmdNext_Click()
If txtInput.Visible Then
Select Case m_Validation
Case "D": 'Date
If Not IsDate(m_Response) Then
MsgBox "Please enter a valid date !", vbCritical
txtInput.SetFocus
Exit Sub
Else
m_Response = CDate(m_Response)
End If

Case "P" 'Percentage
If Not IsNumeric(m_Response) Then
MsgBox "Please enter a valid % !", vbCritical
txtInput.SetFocus
Exit Sub
Else
m_Response = Format(m_Response, "0.00%")
End If

Case "N" 'Numeric - Currency - Term Lenght - Age etc
If Not IsNumeric(m_Response) Then
MsgBox "Please enter a valid Number !", vbCritical
txtInput.SetFocus
Exit Sub
Else
m_Response = CDbl(m_Response)
End If

Case "T": 'Free Flow Text
m_Response = DoSpellCheck(m_Response)
Case Else: m_Response = DoSpellCheck(m_Response)

End Select

End If

Call SaveData(m_QID, m_Question, m_Response, m_PCSOutput)
m_QID = m_Next_QID(m_ItemNo)

Call Question_Load
cmdNext.Enabled = (m_Response <> "")
CmdPrevQuestion.Enabled = True
End Sub
Private Sub CmdPrevQuestion_Click()


If m_QID = 1 Then
m_QID = 1
CmdPrevQuestion.Enabled = False
Else
m_QID = QID_Prev(m_Question)
Call Question_Load

CmdPrevQuestion.Enabled = True
End If

End Sub
Private Sub txtInput_Change()
cmdNext.Enabled = (txtInput.text <> "")
'm_Validation
m_Response = txtInput.text
End Sub
Private Sub UserForm_Initialize()

m_QID = 1
m_TotalUniqueQuestions = TotalQuestions
Call Question_Load
End Sub
Private Sub Question_Load()

Dim intTotalOptions As Integer
Dim strQInfo(4) As String
Dim strOptionsID() As String
Dim strOptions() As String
Dim intOptionsControl As Integer
Dim intOptions As Integer

ReDim m_Next_QID(0)
ReDim m_Prev_QID(0)

Call Question_Detail(m_QID, strQInfo, intTotalOptions, strOptionsID, strOptions, m_Next_QID, m_Prev_QID, intOptionsControl)

'Update Memory Variables
m_Question = strQInfo(1)
m_Validation = strQInfo(3)
m_PCSOutput = strQInfo(4) 'Get PCS Output Information
m_Response = QuestionAnswer(m_Question)
m_ItemNo = 1
'Load Controls with Data
Me.Label2.Width = 296 * (m_QID / m_TotalUniqueQuestions)
Me.Label2.Caption = Format((m_QID / m_TotalUniqueQuestions), "0.0%")
Me.lblQID.Caption = m_QID
Me.lblQuestion.Caption = m_Question
Me.LblDesc.Caption = strQInfo(2)

'Hide all Controls
cmbOptions.Visible = False
txtInput.Visible = False

'Decide which control should be displayed
Select Case intOptionsControl
Case CTRL_OPTION:
Case CTRL_CHECKBOX:
Case CTRL_LISTBOX:
Case CTRL_COMBOBOX: 'Set Combobox
With cmbOptions
.Clear
.Visible = True
For intOptions = 1 To intTotalOptions
.AddItem strOptions(intOptions)
If strOptions(intOptions) = m_Response Then .ListIndex = intOptions - 1
Next intOptions

End With

Case CTRL_TEXTBOX:
txtInput.Value = m_Response
txtInput.Visible = True

Case Else:
txtInput.Visible = True

End Select
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, Closemode As Integer)

If Closemode = vbFormControlMenu Then
MsgBox "Please use the End button to close the form", vbCritical
Cancel = True
End If
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,214,527
Messages
6,120,058
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top