帮我看看这个调用程序怎么写
那个按纽功能怎么弄啊,关键
·清除列表框和文本框中的内容
·使“删除项目”按纽禁用
·在第三个标签中显示当前列表框中的项目数
(7)单击“退出”按纽后,结束程序运行
[此贴子已经被作者于2007-6-4 15:24:44编辑过]
[此贴子已经被作者于2007-6-4 15:24:44编辑过]
Private Sub Command1_Click()
If Text1.Text <> "" Then
For i = 0 To List1.ListCount
If Text1.Text = List1.List(i) Then
MsgBox "该学生已经存在!"
Exit Sub
End If
Next i
List1.AddItem Text1.Text
Label3.Caption = List1.ListCount
End If
End Sub
Private Sub Command2_Click()
Dim r As Integer
If List1.ListIndex <> -1 Then
r = MsgBox(" 您确定要删除该项目?", vbInformation + vbYesNo)
If r = vbYes Then
List1.RemoveItem List1.ListIndex
Label3.Caption = List1.ListCount
If List1.ListCount = 0 Then
Text1.Text = ""
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
End If
End If
Else
MsgBox "没有选择学生,不能删除列表项!"
End If
End Sub
Private Sub Command3_Click()
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
If List1.Columns = 0 Then
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
End If
End Sub
Private Sub Text1_Click()
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
End Sub
我的代码是:
Private Sub Command1_Click()
List1.AddItem Text1.Text
Text1.Text = ""
Text1.SetFocus
Label3.Caption = List1.ListCount
End Sub
Private Sub Command2_Click()
List1.RemoveItem List1.ListIndex
Label3.Caption = List1.ListCount
End Sub
Private Sub Command3_Click()
List1.Clear
Text1.Text = ""
Command2.Enabled = False
Label3.Caption = List1.ListCount
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
End Sub
Private Sub Text1_Change()
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
End Sub
谢谢你,站们可以好好交流一下