Hi,

I am needing to add a listbox to the code below. That allows a user to select multiple options. Please can someone let me know how?





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 Length - 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: 'Set Listbox
With cmbOptions
.Clear
.Visible = True
For intOptions = 3 To intTotalOptions
.AddItem? strOptions(intOptions)
If strOptions(intOptions) = m_Response Then .ListIndex = intOptions - 1
Next intOptions

End With
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