Good answer Mark, but remember that the shellsort is on of the slowest sorts
for large numbers of items (1000+). Do a search for a mergesort and vb. The
mergesort is the fastest sort for more than 15 entities. The general
strategy would be to use mergesort to break down the list into sub lists of
15 items, then shellsort the small list, and do the recursive merge back up
the tree. I have used this often, and it is fast for large lists 60k-100k
items.
HTH
//chris
"Mark Propst"
wrote in message
news:[email protected]...
>
> "Frank Jan Koole" wrote in message
> news:[email protected]...
> > I have a few sub's and after searching on the internet, in this NG and
in
> > the help I came to the conclusion that an array is what I'm looking for.
>
> > I also have a sub where I want to fill an array with strings and sort
> those
> > strings alphabatic, but I don't know how?
> > I hope anybody can help me with this and can explain a little about
> array's?
>
> I found it on the web somewhere during many searches for sorting
algorithms
> I don't remember which one should get credit for this version...sorry....
>
> I think this will work for your string array
> Sub SHELLSORTtxt(arr)
> Dim gappos As Integer
> Dim swapped As Boolean
> Dim tmp As Long
> Dim tmpstr As String
>
> gappos = UBound(arr) \ 2
> Do While gappos <> 0
> Do
> swapped = False
> For tmp = 0 To UBound(arr) - gappos
> If (StrComp(arr(tmp + gappos), arr(tmp), vbTextCompare) = -1) Then
> tmpstr = arr(tmp + gappos)
> arr(tmp + gappos) = arr(tmp)
> arr(tmp) = tmpstr
> swapped = True
> End If
> Next tmp
> Loop Until Not swapped
> gappos = gappos \ 2
> Loop
> End Sub
>
> Ive also found some here
> ' Chris Rae's VBA Code Archive - http://chrisrae.com/vba
>
> do a google search on sorting and you'll find many information
>
> basically an array you have to create the size you need it
> Dim myArray(3) as String
> will hold 4 strings
>
> then you have to fill it one by one, each element
>
> myArray(0)= "A"
> myArray(1)="B"
> etc
> and also read it one by one
> For i = 0 to 3
> debug.print myarray(i)
> next
>
> hth
> Mark
>
>