MSHFlexGrid多列排序
一萬行,3秒搞定
Const ASC As Long = 1
Const DESC As Long = -1
Private SortType As Long
Private Sub Command1_Click()
SortType = ASC
Debug.Print Now
MSHFlexGrid1.Sort = 9
Debug.Print Now
End Sub
Private Sub Command2_Click()
SortType = DESC
MSHFlexGrid1.Sort = 9
End Sub
Private Sub Form_Load()
Randomize
With MSHFlexGrid1
For i = 1 To .Rows - 1
.TextMatrix(i, 3) = CStr(i)
.TextMatrix(i, 1) = Format(Rnd, "0.0")
Next
End With
End Sub
Private Sub MSHFlexGrid1_Compare(ByVal Row1 As Long, ByVal Row2 As Long, Cmp As Integer)
Dim x1 As Double, x2 As Double, n1 As Long, n2 As Long
x1 = CDbl(MSHFlexGrid1.TextMatrix(Row1, 1))
x2 = CDbl(MSHFlexGrid1.TextMatrix(Row2, 1))
If x1 < x2 Then
Cmp = -1
ElseIf x1 > x2 Then
Cmp = 1
Else "第一列相等的情況下,按第三列排序
n1 = CLng(MSHFlexGrid1.TextMatrix(Row1, 3))
n2 = CLng(MSHFlexGrid1.TextMatrix(Row2, 3))
If n1 < n2 Then
Cmp = -1
ElseIf n1 > n2 Then
Cmp = 1
Else
Cmp = 0
End If
End If
Cmp = Cmp * SortType
End Sub[@more@]
Const ASC As Long = 1
Const DESC As Long = -1
Private SortType As Long
Private Sub Command1_Click()
SortType = ASC
Debug.Print Now
MSHFlexGrid1.Sort = 9
Debug.Print Now
End Sub
Private Sub Command2_Click()
SortType = DESC
MSHFlexGrid1.Sort = 9
End Sub
Private Sub Form_Load()
Randomize
With MSHFlexGrid1
For i = 1 To .Rows - 1
.TextMatrix(i, 3) = CStr(i)
.TextMatrix(i, 1) = Format(Rnd, "0.0")
Next
End With
End Sub
Private Sub MSHFlexGrid1_Compare(ByVal Row1 As Long, ByVal Row2 As Long, Cmp As Integer)
Dim x1 As Double, x2 As Double, n1 As Long, n2 As Long
x1 = CDbl(MSHFlexGrid1.TextMatrix(Row1, 1))
x2 = CDbl(MSHFlexGrid1.TextMatrix(Row2, 1))
If x1 < x2 Then
Cmp = -1
ElseIf x1 > x2 Then
Cmp = 1
Else "第一列相等的情況下,按第三列排序
n1 = CLng(MSHFlexGrid1.TextMatrix(Row1, 3))
n2 = CLng(MSHFlexGrid1.TextMatrix(Row2, 3))
If n1 < n2 Then
Cmp = -1
ElseIf n1 > n2 Then
Cmp = 1
Else
Cmp = 0
End If
End If
Cmp = Cmp * SortType
End Sub[@more@]
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/778857/viewspace-977300/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Datatable多列排序排序
- 多維陣列排序陣列排序
- linux sort 多列正排序,倒排序Linux排序
- PHP 多維陣列排序PHP陣列排序
- Awk 陣列排序多種實現方法陣列排序
- PHP陣列多個欄位分別排序PHP陣列排序
- 【新特性速遞】表格多列排序(SortingMulti)排序
- 多維陣列按鍵名進行重新排序陣列排序
- PHP指定欄位的多維陣列排序方法PHP陣列排序
- PHP 多維陣列排序-按某個 key 的值PHP陣列排序
- 陣列排序陣列排序
- Arr::sort()輔助函式對多維陣列的排序函式陣列排序
- 陣列的排序陣列排序
- 物件陣列排序物件陣列排序
- JavaScript 陣列排序JavaScript陣列排序
- js陣列排序JS陣列排序
- 【佇列】【懶排序】佇列Q佇列排序
- 歸併排序:陣列和連結串列的多種實現排序陣列
- Java 物件陣列多屬性條件排序問題(詳解)Java物件陣列排序
- 為什麼處理排序陣列比未排序陣列快排序陣列
- jquery [datatable]排序時指定某列不可排序jQuery排序
- 陣列氣泡排序陣列排序
- 陣列選擇排序陣列排序
- js陣列排序整理JS陣列排序
- javascript 陣列快速排序JavaScript陣列排序
- 陣列多重排序陣列排序
- c# 陣列排序C#陣列排序
- 二維陣列排序陣列排序
- ***PHP陣列排序+php二維陣列排序方法(PHP比較器)PHP陣列排序
- Exce使用VBA對多於4列的資料進行組合排序排序
- 多關鍵字排序排序
- 二位陣列排序陣列排序
- 陣列排序的實現陣列排序
- php 二維陣列排序PHP陣列排序
- c++陣列排序插入C++陣列排序
- 二維陣列行排序陣列排序
- js:陣列自定義排序JS陣列排序
- 陣列排序(從小到大)陣列排序