If List1.ListIndex <> 0 Then
List1.Text = List1.List(List1.ListIndex - 1) '上移
End If
If List1.ListIndex <> List1.ListCount - 1 Then
List1.Text = List1.List(List1.ListIndex + 1) '下移
End If
List1.Text = List1.List(List1.ListIndex - 1) '上移
End If
If List1.ListIndex <> List1.ListCount - 1 Then
List1.Text = List1.List(List1.ListIndex + 1) '下移
End If
不過應該改成 If List1.ListIndex > 0 因為可肯為-1
List1.ListIndex= List1.ListIndex- 1) '上移
End If
If List1.ListIndex <> List1.ListCount - 1 Then
List1.ListIndex=List1.ListIndex + 1) '下移
End If
Dim str1$Private Sub Command1_Click()
If List1.ListIndex > -0 Then
str1 = List1.List(List1.ListIndex - 1)
List1.List(List1.ListIndex - 1) = List1.List(List1.ListIndex) '上移
List1.List(List1.ListIndex) = str1
List1.ListIndex = List1.ListIndex - 1
End IfEnd SubPrivate Sub Command2_Click()
If List1.ListIndex <> List1.ListCount - 1 Then
str1 = List1.List(List1.ListIndex + 1)
List1.List(List1.ListIndex + 1) = List1.List(List1.ListIndex) '下移
List1.List(List1.ListIndex) = str1
List1.ListIndex = List1.ListIndex + 1
End If
End Sub
Private Sub cmddrown_Click()
Dim sRomveName As String '被移动的名称
Dim nlstselectItme As Long '被选项值
nlstselectItme = lstSelectName.ListIndex
If nlstselectItme < lstSelectName.ListCount - 1 Then
sRomveName = lstSelectName.List(nlstselectItme)
lstSelectName.RemoveItem nlstselectItme
lstSelectName.AddItem sRomveName, nlstselectItme + 1
lstSelectName.ListIndex = nlstselectItme + 1
End If
End Sub'上移
Private Sub cmdup_Click()
Dim sRomveName As String '被移动的名称
Dim nlstselectItme As Long '被选项值
nlstselectItme = lstSelectName.ListIndex
If nlstselectItme > 0 Then
sRomveName = lstSelectName.List(nlstselectItme)
lstSelectName.RemoveItem nlstselectItme
lstSelectName.AddItem sRomveName, nlstselectItme - 1
lstSelectName.ListIndex = nlstselectItme - 1
End If
End Sub