vb题,请高手帮我解决一哈

2025-02-23 12:57:40
推荐回答(4个)
回答1:

按你说的效果做了下面的程序
Private Sub Command1_Click()
List1.AddItem Text1.Text
Label3.Caption = Val(Label3.Caption) + 1
Command3.Enabled = True
Text1.Text = ""
End Sub

Private Sub Command2_Click()
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) = True Then
List1.RemoveItem (i)
Label3.Caption = Val(Label3.Caption) - 1
End If
Next i
Command2.Enabled = False
If List1.ListCount = 0 Then
Command3.Enabled = False
End If
End Sub

Private Sub Command3_Click()
List1.Clear
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Label3.Caption = "0"
End Sub

Private Sub Command4_Click()
Unload sy4-3 '电脑上这个名称好像用不了
End Sub

Private Sub Form_Load()
Label1.Caption = "请输入院系名称"
Label2.Caption = "院系个数:"
Label3.Caption = "0"
Text1.Text = ""
Command1.Caption = "增加项目"
Command2.Caption = "删除项目"
Command3.Caption = "清除项目"
Command4.Caption = "退出"
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
End Sub

Private Sub List1_Click()
Command2.Enabled = True
End Sub

Private Sub Text1_Change()
If Len(Trim(Text1.Text)) <> 0 Then
Command1.Enabled = True
Else
Command1.Enabled = False
End If
End Sub
代码我已经在电脑上试过了,和你说的效果差不多,应该能满足你的要求!!!

回答2:

Private Sub Command1_Click()
List1.AddItem Text1
Text1 = ""
Command3.Enabled = True
Label3 = List1.ListCount
End Sub

Private Sub Command2_Click()
List1.RemoveItem List1.ListIndex
Command2.Enabled = False
If List1.ListCount = 0 Then
Command3.Enabled = False
End If
Label3 = List1.ListCount
End Sub

Private Sub Command3_Click()
List1.Clear
Command3.Enabled = False
Label3 = "0"
End Sub

Private Sub Command4_Click()
End
End Sub

Private Sub Form_Load()
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Label1 = "请输入院系名称"
Label2 = "院系个数:"
Label3 = "0"
Command1.Caption = "添加项目"
Command2.Caption = "删除项目"
Command3.Caption = "清除项目"
Command4.Caption = "退出"
Text1 = ""
End Sub

Private Sub List1_Click()
If List1.ListIndex <> -1 Then
Command2.Enabled = True
End If
End Sub
Private Sub Text1_Change()
If Len(Text1) Then
Command1.Enabled = True
Else
Command1.Enabled = False
End If
End Sub

回答3:

'工程文件名为sy4-3.vbp,窗体文件名为sy4-3.frm
Option Explicit
Private Sub Command1_Click()
List1.AddItem Text1
Label3 = Label3 + 1
Command3.Enabled = True
Text1 = ""
End Sub
Private Sub Command2_Click()
Dim i&
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
List1.RemoveItem i
Label3 = Label3 - 1
Command2.Enabled = False
If Label3 = 0 Then Command3.Enabled = False
Exit Sub
End If
Next
End Sub
Private Sub Command3_Click()
List1.Clear
Label3 = 0
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Caption = "列表框使用"
Command1.Caption = "添加项目"
Command2.Caption = "删除项目"
Command3.Caption = "清除项目"
Command4.Caption = "退出"
Label1 = "请输入院校名称"
Label2 = "院系个数"
Label3 = 0
Text1 = ""
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
End Sub
Private Sub List1_Click()
Dim i&
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then Command2.Enabled = True
Next
End Sub
Private Sub Text1_Change()
If Text1 = "" Then Command1.Enabled = False Else Command1.Enabled = True
End Sub

回答4:

http://www.set2get.com/ftpUploadfile/sbscn/tempfile_30M/147474557.rar

已经做好的程序 你看看 下载完告诉一声 稍后删除