views:

843

answers:

1

I currently have a VB6 program that essential reads data from an excel worksheet and spits it out into a MSFlexGrid.

Below is the excel sheet data that is read in. Data is filled into the occurence column for the left half of the table.

The VB6 Application then read this data into a multi dimensional array which is then fed into a MSFlexGrid object. Here is the code to do that:

Private Sub GridSort(temp() As String)
fgData.Rows = UBound(temp)
x = 0
 Do While x < fgData.Rows
    fgData.Row = x
    fgData.Col = 0
    fgData.Text = temp(x, 0)
    fgData.Col = 1
    fgData.Text = temp(x, 1)
    x = x + 1
  Loop
  fgData.ColSel = 1
  fgData.Sort = flexSortGenericDescending
  x = 0
  Do While x < fgData.Rows
    fgData.Row = x
    fgData.Col = 0
    temp(x, 0) = fgData.Text
    fgData.Col = 1
    temp(x, 1) = fgData.Text
    x = x + 1
  Loop

End Sub

Now this works to a degree. It sorts the Data by occurences and outputs as so:

However, you can see that it messed up the order of the first column. I want the data to be sorted by occurences first, but for data with the same amount of occurences, I want them sorted by operation. Does anybody know a way to accomplish this?

+1  A: 

The MSFlexGrid is sorting data in multiple columns by sorting the columns from left to right and always in the same order (descending/ascending). So you could swap the columns "occurence" and "operation" to achieve your goal.

Elsewhise, I found here a nice collection of MSFlexGrid functions and there's also one entry for multi-column sorting. Look for the entry "Sorting multiple columns". Didn't test it, but you could give it a try.

MicSim