Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.



Public Function QCSortlng(strList() As Long, ByVal lLbound As Long, ByVal lUbound As Long, ByVal boolCaseSensitive As Boolean, intColumn As Integer)
' Procedure :   strFmtDec
' Description:  Simple format of a numeric value.
' Copyright:    Chris Greaves Inc.
' Inputs:       Variant value, INTEGER number of decimal places
' Returns:      STRING.
' Assumes:      None.
' Side Effects: None.
' Tested:       By the calls below.
' March 3rd Chris Greaves Implemented a Column key (hence qCsort)
    Dim strTemp As Long
'Procs    Dim strBuffer() As Long
    Dim lngCurLow As Long
    Dim lngCurHigh As Long
    Dim lngCurMidpoint As Long
    lngCurLow = lLbound ' Start current low and high at actual low/high
    lngCurHigh = lUbound
    If lUbound <= lLbound Then Exit Function ' Error!
    lngCurMidpoint = (lLbound + lUbound) \ 2 ' Find the approx midpoint of the array
    strTemp = strList(lngCurMidpoint, intColumn) ' Pick as a starting point (we are making
    ' an assumption that the data *might* be in semi-sorted order already!
    Do While (lngCurLow <= lngCurHigh)
        Do While strList(lngCurLow, intColumn) < strTemp
            lngCurLow = lngCurLow + 1
            If lngCurLow = lUbound Then Exit Do
        Loop
        Do While strTemp < strList(lngCurHigh, intColumn)
            lngCurHigh = lngCurHigh - 1
            If lngCurHigh = lLbound Then Exit Do
        Loop
        If (lngCurLow <= lngCurHigh) Then ' if low is <= high then swap
            Call SwapRowslng(strList, lngCurLow, lngCurHigh)
            lngCurLow = lngCurLow + 1 ' CurLow++
            lngCurHigh = lngCurHigh - 1 ' CurLow--
        End If
    Loop
    If lLbound < lngCurHigh Then ' Recurse if necessary
        QCSortlng strList(), lLbound, lngCurHigh, boolCaseSensitive, intColumn
    End If
    If lngCurLow < lUbound Then ' Recurse if necessary
        QCSortlng strList(), lngCurLow, lUbound, boolCaseSensitive, intColumn
    End If
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1

Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.

Public Function QCSortlng(strList() As Long, ByVal lLbound As Long, ByVal lUbound As Long, ByVal boolCaseSensitive As Boolean, intColumn As Integer)
' Procedure :   strFmtDec
' Description:  Simple format of a numeric value.
' Copyright:    Chris Greaves Inc.
' Inputs:       Variant value, INTEGER number of decimal places
' Returns:      STRING.
' Assumes:      None.
' Side Effects: None.
' Tested:       By the calls below.
' March 3rd Chris Greaves Implemented a Column key (hence qCsort)
    Dim strTemp As Long
'Procs    Dim strBuffer() As Long
    Dim lngCurLow As Long
    Dim lngCurHigh As Long
    Dim lngCurMidpoint As Long
    lngCurLow = lLbound ' Start current low and high at actual low/high
    lngCurHigh = lUbound
    If lUbound <= lLbound Then Exit Function ' Error!
    lngCurMidpoint = (lLbound + lUbound) \ 2 ' Find the approx midpoint of the array
    strTemp = strList(lngCurMidpoint, intColumn) ' Pick as a starting point (we are making
    ' an assumption that the data *might* be in semi-sorted order already!
    Do While (lngCurLow <= lngCurHigh)
        Do While strList(lngCurLow, intColumn) < strTemp
            lngCurLow = lngCurLow + 1
            If lngCurLow = lUbound Then Exit Do
        Loop
        Do While strTemp < strList(lngCurHigh, intColumn)
            lngCurHigh = lngCurHigh - 1
            If lngCurHigh = lLbound Then Exit Do
        Loop
        If (lngCurLow <= lngCurHigh) Then ' if low is <= high then swap
            Call SwapRowslng(strList, lngCurLow, lngCurHigh)
            lngCurLow = lngCurLow + 1 ' CurLow++
            lngCurHigh = lngCurHigh - 1 ' CurLow--
        End If
    Loop
    If lLbound < lngCurHigh Then ' Recurse if necessary
        QCSortlng strList(), lLbound, lngCurHigh, boolCaseSensitive, intColumn
    End If
    If lngCurLow < lUbound Then ' Recurse if necessary
        QCSortlng strList(), lngCurLow, lUbound, boolCaseSensitive, intColumn
    End If
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1