Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
AddBookName = InputBox("请输入要添加的图书资料名称:", "添加图书资料")
List1.AddItem AddBookName
Case 1
If List1.ListIndex < 0 Then
MsgBox "请选择要删除的图书资料!", vbExclamation
Else
List1.RemoveItem List1.ListIndex
End If
Case 2
If List1.ListIndex < 0 Then
MsgBox "上移前,请先选定一个列表项!", vbExclamation
ElseIf List1.ListIndex = 0 Then
MsgBox "到顶了,不能再上移了!", vbCritical
Else
temp = List1.ListIndex
List1.AddItem List1.List(List1.ListIndex), List1.ListIndex - 1
List1.RemoveItem List1.ListIndex
List1.ListIndex = temp - 1
End If
Case 3
If List1.ListIndex < 0 Then
MsgBox "下移前,请先选定一个列表项!", vbExclamation
ElseIf List1.ListIndex = List1.ListCount - 1 Then
MsgBox "到底了,不能再下移了!", vbCritical
Else
temp = List1.ListIndex
List1.AddItem List1.List(List1.ListIndex), List1.ListIndex + 2
List1.RemoveItem List1.ListIndex
List1.ListIndex = temp + 1
End If
Case 4
List1.ListIndex = 0
Case 5
List1.ListIndex = List1.ListCount - 1
End Select
End Sub
Private Sub Form_Load()
List1.AddItem "计算机文化基础"
List1.AddItem "FORTRAN程序设计"
List1.AddItem "Quick Basic 程序设计"
List1.AddItem "C程序设计教程"
List1.AddItem "Visual Basic程序设计教程"
List1.AddItem "网页制作基础"
List1.AddItem "Visual FoxPro数据库设计教程"
List1.AddItem "计算机接口技术"
List1.AddItem "网络操作系统"
List1.AddItem "图形处理技术"
List1.AddItem "网络安全与管理"
List1.AddItem "软盘加密与解密技术"
End Sub