VBA ListBox in ACAD does not do sorting for you. You have do it yourself:
put all layers' name in an string array; choose one of your favorite sorting
algrithm and write your sorting code; sort the array, and then popualte the
listbox/combobox.
Actaully, you do not have to write your onw sorting code, there are a lot
ready to use sorting algrithms on the net. You can google some VB/VBA
related news group for "sorting". Here is one example of what I have found:
Public Sub ShellSort(ByRef A() As Variant, _
ByVal Lb As Long, ByVal Ub As Long)
Dim n As Long, h As Long
Dim i As Long, j As Long
Dim t As Variant
'
' ***** If you are using this routine to sort string data and you want
' it to be case insensitive (ie "cat" comes before "Dog") then you
' must place the line "Option Compare Text" in the (general)
' (declarations) section of the Form or Module in which this routine
' is declared
' *******************************
'
' We allow the user to send his own start and end positions to
' this routine in case he wants to sort only part of the array
' (which is a common requirement) so we must first check and
' adjust those parameters in case he has given us silly numbers!
If Ub > UBound(A) Then Ub = UBound(A)
If Lb < LBound(A) Then Lb = LBound(A)
If Lb >= Ub Then Exit Sub
'
' now sort array (from element lb to element ub)
' first calculate the largest increment
n = Ub - Lb + 1
h = 1
If n > 13 Then
Do While h < n
h = 3 * h + 1
Loop
h = h \ 3
If h > (n * 0.8) Then h = h \ 3
End If
' repeatedly do an insertion sort using
' values of h from its initial value down
' to a value of 1
Do While h > 0
For i = Lb + h To Ub
t = A(i)
For j = i - h To Lb Step -h
If A(j) <= t Then Exit For
A(j + h) = A(j)
Next j
A(j + h) = t
Next i
h = h \ 3
Loop
End Sub
"Pienpeas" wrote in message
news:26404003.1088086651697.JavaMail.jive@jiveforum2.autodesk.com...
> Hi,
>
> Simple question, I've populated a listbox with layer names but they are in
no certain order. I thought that the listbox has a sorted property but it
wont let me do
>
> Listbox1.sorted=true
>
> Any help appreciated
>
> Al