|
Поменять местами два рядом стоящих элемента |
|
|
Расположите на форме 2 элемента CommandButton и элемент ListBox. Private Sub Command1_Click()
With List1
If .ListIndex < 0 Then Exit Sub
nItem = .ListIndex
If nItem = 0 Then Exit Sub
.AddItem .Text, nItem - 1
.RemoveItem nItem + 1
.Selected(nItem - 1) = True
End With
End Sub
Private Sub Command2_Click()
With List1
If .ListIndex < 0 Then Exit Sub
nItem = .ListIndex
If nItem = .ListCount - 1 Then Exit Sub
.AddItem .Text, nItem + 2
.RemoveItem nItem
.Selected(nItem + 1) = True
End With
End Sub
Private Sub Form_Load()
List1.AddItem "1"
List1.AddItem "2"
List1.AddItem "3"
List1.AddItem "4"
List1.AddItem "5"
End Sub
|
|
|
|
|
|
|