Variant array of strings
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Variant array of strings

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
VBA
Guest





Posted: Thu Dec 09, 2004 4:56 pm    Post subject: Variant array of strings Reply with quote

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

Back to top
Paul Richardson
Guest





Posted: Thu Dec 09, 2004 5:13 pm    Post subject: Re: Variant array of strings Reply with quote

'*********
' 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...
Quote:
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

Back to top
Jorge Lopez
Guest





Posted: Fri Dec 10, 2004 4:29 am    Post subject: Re: Variant array of strings Reply with quote

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...
Quote:
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



Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB