Results 1 to 3 of 3

Thread: Variant array of strings

  1. #1
    VBA Guest

    Variant array of strings

    I have a variant array of string values [i.e. Dim Unsorted As Variant] and I
    want to sort them.

    Does anyone have a routine that will accomplish this task?

    TIA

  2. #2
    Paul Richardson Guest
    '*********
    ' Bubble Sort an array of any type
    ' Author: The VB2TheMax Team
    Sub BubbleSort(arr As Variant, Optional descending As Boolean, _
    Optional numEls As Variant)

    Dim Value As Variant
    Dim Index As Long
    Dim firstItem As Long
    Dim indexLimit As Long, lastSwap As Long

    ' account for optional arguments
    If IsMissing(numEls) Then numEls = UBound(arr)
    firstItem = LBound(arr)
    lastSwap = numEls

    Do
    indexLimit = lastSwap - 1
    lastSwap = 0
    For Index = firstItem To indexLimit
    Value = arr(Index)
    If (Value > arr(Index + 1)) Xor descending Then
    ' if the items are not in order, swap them
    arr(Index) = arr(Index + 1)
    arr(Index + 1) = Value
    lastSwap = Index
    End If
    Next
    Loop While lastSwap
    End Sub
    '**********
    "VBA" <nospam@nowhere.com> wrote in message news:41b83d5d$1_1@newsprd01...
    I have a variant array of string values [i.e. Dim Unsorted As Variant] and
    I
    want to sort them.

    Does anyone have a routine that will accomplish this task?

    TIA

  3. #3
    Jorge Lopez Guest
    http://www.nist.gov/dads/

    Search for sort and you will see a ton of sort algorithms.

    - Jorge

    "VBA" <nospam@nowhere.com> wrote in message news:41b83d5d$1_1@newsprd01...
    I have a variant array of string values [i.e. Dim Unsorted As Variant] and
    I
    want to sort them.

    Does anyone have a routine that will accomplish this task?

    TIA

Similar Threads

  1. building string out of list of strings
    By Suresh Jeevanandam in forum Cadence
    Replies: 1
    Last Post: 11-30-2005, 05:10 AM
  2. setting variant and object properties when using dll in lisp
    By James Maeding in forum Customization
    Replies: 7
    Last Post: 02-14-2005, 01:32 PM
  3. Problem With Variant
    By TomD in forum VBA
    Replies: 4
    Last Post: 02-14-2005, 11:25 AM
  4. Checking the textmask of two strings
    By Marcel Janmaat in forum Customization
    Replies: 18
    Last Post: 01-28-2005, 02:01 AM
  5. array of strings as parameter to COM
    By tacho_fortin in forum Customization
    Replies: 0
    Last Post: 01-04-2005, 11:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum