Private Sub Form_Load()
List1.AddItem "a"
List1.AddItem "b"
List1.AddItem "c"
List1.AddItem "d"
List1.AddItem "e"
List1.Selected(0) = True
End Sub
Private Sub List1_Click()
Text1 = List1.ListIndex
End Sub
Private Sub List1_KeyUp(KeyCode As Integer, Shift As Integer)
Text1 = List1.ListIndex
End Sub
'上移
Private Sub Command1_Click()
Dim i As Integer
Dim s As String
i = List1.ListIndex
If i > 0 Then
s = List1.List(i)
List1.RemoveItem i
List1.AddItem s, i - 1
End If
If Text1 <> "0" Then
Text1.Text = Text1.Text - 1
End If
List1.Selected(Text1.Text) = True
End Sub
'下移
Private Sub Command2_Click()
Dim i As Integer
Dim s As String
i = List1.ListIndex
If i > -1 And i < List1.ListCount - 1 Then
s = List1.List(i)
List1.RemoveItem i
List1.AddItem s, i + 1
End If
If Text1 < (List1.ListCount - 1) Then
Text1.Text = Text1.Text + 1
End If
List1.Selected(Text1.Text) = True
End Sub
Private Sub Text1_Change()
List1.Selected(Text1.Text) = True
End Sub