Advertisement
5_2007-2008 VB function enhancement #172844

SortFlex

Handle the sorting of a MSFlexgrid by only one sub-routine. Automatic ascenting and decending displayed by + and - in the Headline.

AI

Podsumowanie AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Kod źródłowy
original-source
'
' 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
Upload
Oryginalne komentarze (3)
Odzyskane z Wayback Machine