by Dirk (1 Submission)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
Handle the sorting of a MSFlexgrid by only one sub-routine. Automatic ascenting and decending displayed by + and - in the Headline.
Inputs
syntax:
SortFlex MSFlexGrid, CollumToSort , StringSortAsBoolean , StringSortAsBoolean ...
example:
SortFlex flxProject, flxProject.MouseCol, False, True, True, True
'
' 1999 by Dirk Bujna - [email protected]
'
Public Sub SortFlex(FlexGrid As MSFlexGrid, TheCol As Integer, ParamArray IsString() As Variant)
FlexGrid.Col = TheCol
For i = 0 To FlexGrid.Cols - 1
Headline = FlexGrid.TextMatrix(0, i)
Ascend = Right$(Headline, 1) = "+"
Decend = Right$(Headline, 1) = "-"
If Ascend Or Decend Then Headline = Left$(Headline, Len(Headline) - 1)
If i = TheCol Then
If Ascend Then
FlexGrid.TextMatrix(0, i) = Headline & "-"
If IsMissing(IsString(i)) Then
FlexGrid.Sort = flexSortGenericDescending
Else
If IsString(i) Then
FlexGrid.Sort = flexSortStringDescending
Else
FlexGrid.Sort = flexSortNumericDescending
End If
End If
Else
FlexGrid.TextMatrix(0, i) = Headline & "+"
If IsMissing(IsString(i)) Then
FlexGrid.Sort = flexSortGenericAscending
Else
If IsString(i) Then
FlexGrid.Sort = flexSortStringAscending
Else
FlexGrid.Sort = flexSortNumericAscending
End If
End If
End If
Else
FlexGrid.TextMatrix(0, i) = Headline
End If
Next i
End Sub