A Slight Mod
This Will Allow You To Move A Selected Item Up Or Down, But It Will Roll Over From The Bottom To the Top And From the Top To the Bottom.
Note This Is A Checked Listbox
Private Sub cmdMove_Click(Index As Integer)
On Error Resume next
If List1.ListCount < 1 Then
Exit Sub
End If
Dim strTemp As String
Dim intPos As Integer
Dim MySelectionChecked As Boolean
'
strTemp = List1.List(List1.ListIndex)
intPos = List1.ListIndex
If List1.Selected(intPos) = True Then
MySelectionChecked = True
Else
MySelectionChecked = False
End If
If Index = 0 Then
If intPos - 1 >= 0 Then
List1.RemoveItem List1.ListIndex
List1.AddItem strTemp, intPos - 1
List1.ListIndex = intPos - 1
List1.Selected(intPos - 1) = MySelectionChecked
Else
List1.RemoveItem List1.ListIndex
List1.AddItem strTemp
List1.ListIndex = List1.ListCount - 1
List1.Selected(List1.ListCount - 1) = MySelectionChecked
End If
Else
If intPos + 1 < List1.ListCount Then
List1.RemoveItem List1.ListIndex
List1.AddItem strTemp, intPos + 1
List1.ListIndex = intPos + 1
List1.Selected(intPos + 1) = MySelectionChecked
Else
List1.RemoveItem List1.ListIndex
List1.AddItem strTemp, 0
List1.ListIndex = 0
List1.Selected(0) = MySelectionChecked
End If
End If
End Sub