Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 25,317 times

Related Categories

Quick Sort Sample

mrjdesign

This function will fix the eternal sorting dilemma with numerical orders. But there are a few restrictions in it.

1) it doesn't deal with decimal values
2) the numerical value must be a value acceptable to Visual Basic up to CDec(Number)

in other words any given whole numerical value
>= 0 And <= 99999999999999999999999999999
is acceptable even though the highest value possible for use in VB is
79,228,162,514,264,337,593,543,950,335

This function basically fixes the dilemma of the sort order ending up with

1,2,3,30,3000, 31,39,40,400,90000

and so on, to being

1,2,3,30,31,39,40,400,3000,90000.

Something we all wonder I guess why MS didn't do from the start. Assumed that this is place din a form with a label named lblStatus and that you call it by passing a variant type array to it. after fix, the variant type array will be in sorted order.

Function MRJNumericalOrder(ByRef vArray As Variant)
On Error GoTo EEvt
Dim I As Long, vData As Variant
Dim X As Long, TArr() As Variant, Z As Long

ReDim TArr(UBound(vArray))

For X = 1 To 29
DoEvents
   For I = 0 To UBound(vArray)
   DoEvents
   If Len(vArray(I)) = X Then
     TArr(Z) = vArray(I)
     vArray(I) = ""
     Z = Z + 1
   End If
Next I

   'message here StatusIO
Me.lblStatus.Caption = Format(X / 30, "Percent") & " done..."

Next X

'put it all back in the original array
For I = 0 To UBound(vArray)
DoEvents
   vArray(I) = TArr(I)

  'message here StatusIO
   Me.lblStatus.Caption = "Integer Order " & Format(I / UBound(vArray), "Percent") & " done..."
Next I
'
Exit Function
EEvt:
'stop here
'put your error trapping here
Err.Clear
Resume Next
End Function /html>


©2001 - All Rights Reserved - MRJ Design
The source code samples and information pertained within this document are considered copyrighted material and may not be re-distributed by electronic or other media in any form or fashion whatsoever, withou

Comments