Word 2003
Cum ordonez alfabetic printr-o apasare de buton CommandButton1_Click() ?
Private Sub UserForm_Initialize()
'Creates and assigns the Array to the ListBox when the form loads.
Dim mylist As Variant
mylist = Array("Sunday", "Monday", "Tuesday", "Wednesday", _
"Thursday", "Friday", "Saturday")
ListBox1.List = mylist
End Sub
Multumesc
ListBox ordonare alfabetica
Re: ListBox ordonare alfabetica
am gasit urmatoarea varianta:
Private Sub CommandButton3_Click()
Dim lZeile As Long ' For/Next Zeilen-Index
Dim lIndxA As Long ' For/Next Index - außen
Dim lIndxI As Long ' For/next Index - innen
Dim sTemp As String ' temporärer Zwischenspeicher
For lIndxA = 0 To Me.ListBox1.ListCount - 1
For lIndxI = 0 To lIndxA - 1
If UCase(ListBox1.List(lIndxI)) > UCase(ListBox1.List(lIndxA)) Then
sTemp = ListBox1.List(lIndxI)
ListBox1.List(lIndxI) = ListBox1.List(lIndxA)
ListBox1.List(lIndxA) = sTemp
End If
Next lIndxI
Next lIndxA
End Sub
Private Sub CommandButton3_Click()
Dim lZeile As Long ' For/Next Zeilen-Index
Dim lIndxA As Long ' For/Next Index - außen
Dim lIndxI As Long ' For/next Index - innen
Dim sTemp As String ' temporärer Zwischenspeicher
For lIndxA = 0 To Me.ListBox1.ListCount - 1
For lIndxI = 0 To lIndxA - 1
If UCase(ListBox1.List(lIndxI)) > UCase(ListBox1.List(lIndxA)) Then
sTemp = ListBox1.List(lIndxI)
ListBox1.List(lIndxI) = ListBox1.List(lIndxA)
ListBox1.List(lIndxA) = sTemp
End If
Next lIndxI
Next lIndxA
End Sub