I have a form with two combo boxes a command button and a list box. The first combo box contains the names of the column headers in my list box. The second combo box contains the choices of Ascending or Descending.
When the user clicks the command button (labeled "Sort"
, I would like the listbox data to be sorted according to the column selected in the first combo box in Ascending or Descending according to selection made in second combo box.
My listbox is populated using a string with tabs inserted to give a columnar appearance. I would like to accomplish this through the use of an array as opposed to simply requering the database. Here is were I stand:
'Save contents of list box to an array.
Dim i As Integer, arrInfo() As String
ReDim arrInfo(List1.ListCount - 1)
For i = 0 To List1.ListCount - 1
arrInfo(i) = List1.List(i)
Next
'Clear list box.
List1.ClearBox = True
'Set SortOrder.
'++++++++THIS IS WHAT I AM MISSING+++++++++
'Add items back to list box.
For i = 0 To UBound(arrInfo)
List1.AddItem arrInfo(i)
Next
When the user clicks the command button (labeled "Sort"
My listbox is populated using a string with tabs inserted to give a columnar appearance. I would like to accomplish this through the use of an array as opposed to simply requering the database. Here is were I stand:
'Save contents of list box to an array.
Dim i As Integer, arrInfo() As String
ReDim arrInfo(List1.ListCount - 1)
For i = 0 To List1.ListCount - 1
arrInfo(i) = List1.List(i)
Next
'Clear list box.
List1.ClearBox = True
'Set SortOrder.
'++++++++THIS IS WHAT I AM MISSING+++++++++
'Add items back to list box.
For i = 0 To UBound(arrInfo)
List1.AddItem arrInfo(i)
Next