删除成绩的代码:
Private Sub Command1_Click()
On Error GoTo er
List1.RemoveItem (List1.ListIndex)
Exit Sub
er:
MsgBox "请选择要删除的成绩。"
End Sub
Private Sub Form_Load()
List1.AddItem "80"
List1.AddItem "75"
List1.AddItem "86"
End Sub
Private Sub List1_DblClick()
Form2.Show
Form2.Text1 = Form1.List1.Text
End Sub
'====================================
修改成绩代码:
Private Sub Command1_Click()
If Text1 = "" Then
MsgBox "成绩不能为空"
Else
Form1.List1.AddItem Form2.Text1
Form1.List1.RemoveItem Form1.List1.ListIndex
End If
End Sub
实现列表框选中某一行
例如:选中第一行
List1.ListIndex = 0
Private Sub List1_DblClick()
a = InputBox("")
List1.AddItem a
End Sub
Private Sub Command1_Click() '删除按钮
List1.RemoveItem List1.ListIndex
End Sub
Private Sub Form_Click() '单击空白处添加成绩
List1.AddItem InputBox("请输入新的成绩", "添加成绩")
End Sub
Private Sub List1_DblClick() '双击修改成绩
List1.List(List1.ListIndex) = InputBox("请输入新的成绩", "修改成绩", List1.Text)
End Sub
List1.List(List1.ListIndex) = InputBox("要修改")
List1.RemoveItem List1.ListIndex