VB6.0中如何把Listbox的表项,上移或下移一个位置
有两个button1,button2,点button1向上移动一个,点button2,向下移动一个谁能实现,代码要简洁,我追加50分...
有两个button1,button2,
点button1向上移动一个,
点button2,向下移动一个
谁能实现,代码要简洁,我追加50分 展开
点button1向上移动一个,
点button2,向下移动一个
谁能实现,代码要简洁,我追加50分 展开
1个回答
2009-05-14
展开全部
'上移
Private Sub Command1_Click()
Dim n As Long
Dim s As String
If List1.ListIndex > 0 Then
n = List1.ListIndex
s = List1.List(n)
List1.RemoveItem List1.ListIndex
List1.AddItem s, n - 1
End If
End Sub
'下移
Private Sub Command2_Click()
Dim n As Long
Dim s As String
If List1.ListIndex <> -1 And List1.ListIndex < List1.ListCount - 1 Then
n = List1.ListIndex
s = List1.List(n)
List1.RemoveItem List1.ListIndex
List1.AddItem s, n + 1
End If
End Sub
Private Sub Command1_Click()
Dim n As Long
Dim s As String
If List1.ListIndex > 0 Then
n = List1.ListIndex
s = List1.List(n)
List1.RemoveItem List1.ListIndex
List1.AddItem s, n - 1
End If
End Sub
'下移
Private Sub Command2_Click()
Dim n As Long
Dim s As String
If List1.ListIndex <> -1 And List1.ListIndex < List1.ListCount - 1 Then
n = List1.ListIndex
s = List1.List(n)
List1.RemoveItem List1.ListIndex
List1.AddItem s, n + 1
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询