|
-
Jul 15th, 2023, 05:00 AM
#11
Re: VBFlexGrid Control (Replacement of the MSFlexGrid control)
 Originally Posted by Nouyana
Speed test. 10 000 rows.
VBFlexGrid1_Compare = 3199 ms (BubbleSort) 
MSHFlexGrid1_Compare = 61 ms 
VBFlexGrid1_CompareText = 10 ms. Brilliant!
Code:
Private Sub MSHFlexGrid1_Compare(ByVal Row1 As Long, _
ByVal Row2 As Long, _
Cmp As Integer)
Dim Text1 As String
Dim Text2 As String
With MSHFlexGrid1
Text1 = .TextMatrix(Row1, .Col)
Text2 = .TextMatrix(Row2, .Col)
End With
Dim Lng1 As Long: Lng1 = CLng(Right$(Text1, Len(Text1) - 5&))
Dim Lng2 As Long: Lng2 = CLng(Right$(Text2, Len(Text2) - 5&))
Cmp = Sgn(Lng2 - Lng1)
End Sub
Private Sub VBFlexGrid1_Compare(ByVal Row1 As Long, _
ByVal Row2 As Long, _
ByVal Col As Long, _
Cmp As Long)
Dim Text1 As String
Dim Text2 As String
With VBFlexGrid1
Text1 = .TextMatrix(Row1, Col)
Text2 = .TextMatrix(Row2, Col)
End With
Dim Lng1 As Long: Lng1 = CLng(Right$(Text1, Len(Text1) - 5&))
Dim Lng2 As Long: Lng2 = CLng(Right$(Text2, Len(Text2) - 5&))
Cmp = Sgn(Lng2 - Lng1)
End Sub
Private Sub VBFlexGrid1_CompareText(ByVal Text1 As String, _
ByVal Text2 As String, _
ByVal Col As Long, _
Cmp As Long)
Dim Lng1 As Long: Lng1 = CLng(Right$(Text1, Len(Text1) - 5&))
Dim Lng2 As Long: Lng2 = CLng(Right$(Text2, Len(Text2) - 5&))
Cmp = Sgn(Lng2 - Lng1)
End Sub
Update released.
VBFlexGrid1_Compare now uses a indirect MergeSort instead of BubbleSort. The indirect MergeSort is a bit slower than the normal one.
So I expect that VBFlexGrid1_Compare is now very fast compared to before but slower than VBFlexGrid1_CompareText.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|