
                         Frequently Asked Questions
                                AAVBSort.DLL

                       Last Updated: 09-May-95 13:48



   1. What's New in Version 1.1

        Linear search routines (works on unsorted arrays) and Binary
        search routines (very fast lookup).

        Variants can be part of User Defined types.

        Date type variants can be sorted.

        Easy and quick enabling of extra functionality that come with
        registration..

   1. Does AAVBSort.DLL work with Visual Basic for Applications

   You have discovered that Microsoft has several versions of Visual
   Basic and not all are compatible with the other. AAVBSORT.DLL works
   only with the Visual Basic (VB) traditional programming system and
   not Visual Basic for Applications (VBA). This is because the two
   system use different internal formats for their data. VB uses a VB
   specific format, while VBA uses the newer "safe arrays" of OLE 2.

   At this time, we are evaluating whether to offer a similar product
   to AAVBSORT.DLL for Visual Basic for Applications. The time frame
   for a release would be for the end of this year. I will log your
   interested in this and if (& when) we do offer this product I will
   let you know. Let me know if you would be interested in "beta"
   testing a pre-release version. If you have any specific requirements
   for your VBA applications I would be happy to hear them and we would
   hope to address them in a future product.



   2. Why does SortIdx have an extra 0 in the index array

   The problem appears to be that for each String/Index pair of arrays
   sent to the function, two of the Index entries always come back with
   0 in them when, of course, only one should. The rest of the entries
   appear to be sorted Ok.

   In the simplest demonstration of this:

       Static word(3) As String
       Static num(3) As Integer

       Word(0) = 'x'           Num(0) = 0
       Word(1) = 'y'           Num(1) = 1
       Word(2) = 'z'           Num(2) = 2

   Then call SortIdxString Word() Num()

   The result:

       Word(0) = 'x'           Num(0) = 0
       Word(1) = 'y'           Num(1) = 0
       Word(2) = 'z'           Num(2) = 1

   It doesn't matter whether they come in already sorted as in this
   example, or not.

   The problem is how VB declares arrays. Unlike C++, VB declares an
   extra (hidden) element. If one declares an array Dim Foo(10)  the
   elements declared go from 0 to 10. A C++ programmer would expect
   them to go from 0 to 9 and a COBOL programmer would expect 1 to 10.
   (Only Dartmouth Basic hackers would expect how VB does it :-)

   ----------------------------------------------------------------

   Sub mnuProblemReport1Example_Click ()

      Me.Cls
      Me.Print "Two index entries are always 0 after call"
      Me.Print "to SortIdxString."

      Static word(3) As String
      Static num(3) As Integer

      word(0) = "x"
      word(1) = "y"
      word(2) = "z"

      num(0) = 0
      num(1) = 1
      num(2) = 2

      Dim i As Integer

      Me.Print "Before"

      Me.Print "i", "word(i)", "num(i)"
      For i = LBound(word) To UBound(word)
         Me.Print i, word(i), num(i)
      Next i

      SortIdxString word(), num()

      Me.Print "After"

      Me.Print "i", "word(i)", "num(i)"
      For i = LBound(word) To UBound(word)
         Me.Print i, word(i), num(i)
      Next i

   End Sub

   ----------------------------------------------------------------
   Sub mnuProblemReport1Solution_Click ()
      Me.Cls
      Me.Print "When VB arrays are declared they have a"
      Me.Print "'hidden' 0 element. In this case the "
      Me.Print "'hidden' element was num(3) and Word(3)."

      Static word(2) As String
      Static num(2) As Integer

      word(0) = "x"
      word(1) = "y"
      word(2) = "z"

      num(0) = 0
      num(1) = 1
      num(2) = 2

      Dim i As Integer

      Me.Print "Before"

      Me.Print "i", "word(i)", "num(i)"
      For i = LBound(word) To UBound(word)
         Me.Print i, word(i), num(i)
      Next i
      SortIdxString word(), num()

      Me.Print "After"

      Me.Print "i", "word(i)", "num(i)"
      For i = LBound(word) To UBound(word)
         Me.Print i, word(i), num(i)
      Next i

   End Sub