habe in der Recherche hier, folgenden Code gefunden. Kann mir jemand helfen und mir sagen was ich tuen muss um diesen Code der eine 4-spaltige Listbox sortiert auf eine 6 bzw 8 spaltige Listbox zu erweitern:
Option Explicit
Private Sub CommandButton1_Click()
Dim strSpalte As String
Do
strSpalte = InputBox$("Welche Spalte?", "Eingabe")
strSpalte = Trim$(strSpalte)
If strSpalte = "" Then Exit Sub
If Len(strSpalte) = 1 And InStr(1, "1234", strSpalte) <> 0 Then Exit Do
MsgBox "Nur ganze Zahlen von 1 bis 4 zulässig.", 48, "Hinweis"
Loop
Call sortieren(0, ListBox1.ListCount - 1, CByte(strSpalte))
End Sub
Private Sub sortieren(lngUgrenze As Long, lngOgrenze As Long, bytSpalte As Byte)
Dim lngIndex1 As Long, lngIndex2 As Long, strElement As String
Dim strZwischenspeicher As String, bytIndex As Byte
lngIndex1 = lngUgrenze
lngIndex2 = lngOgrenze
strZwischenspeicher = ListBox1.List(((lngUgrenze + lngOgrenze) / 2) \ 1, bytSpalte - 1)
Do
Do While ListBox1.List(lngIndex1, bytSpalte - 1) < strZwischenspeicher
lngIndex1 = lngIndex1 + 1
Loop
Do While strZwischenspeicher < ListBox1.List(lngIndex2, bytSpalte - 1)
lngIndex2 = lngIndex2 - 1
Loop
If lngIndex1 <= lngIndex2 Then
For bytIndex = 0 To 3
strElement = ListBox1.List(lngIndex1, bytIndex)
ListBox1.List(lngIndex1, bytIndex) = ListBox1.List(lngIndex2, bytIndex)
ListBox1.List(lngIndex2, bytIndex) = strElement
Next
lngIndex1 = lngIndex1 + 1
lngIndex2 = lngIndex2 - 1
End If
Loop Until lngIndex1 > lngIndex2
If lngUgrenze < lngIndex2 Then Call sortieren(lngUgrenze, lngIndex2, bytSpalte)
If lngIndex1 < lngOgrenze Then Call sortieren(lngIndex1, lngOgrenze, bytSpalte)
End Sub
MfG
Holger Wächter