當前位置:編程學習大全網 - 編程軟體 - vb怎麽讓數據庫的信息往上或者往下移動

vb怎麽讓數據庫的信息往上或者往下移動

這裏我用List1控件來演示

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

  • 上一篇:兔子采蘑菇中班科學教案怎麽寫?
  • 下一篇:吉利面試題目總結
  • copyright 2024編程學習大全網