确实太繁琐了,现在上班忙啊,没时间写了。等晚上要是有时间就帮你写一个。
花了点时间写了一下。那个隐藏的功能你知道了就自己加进去,我就没写了。可能有bug,好久没用vb了,挺生疏的。
还有我在日本,机器都是日文系统,vb也是,显示不了中文,其中的名字什么的你自己改成对应的就可以了,我想这不难吧。
晕,果然有bug,改了一下。vb6.0 pass如果再有bug你自己改吧。
Public c As Boolean 'to make sure there are not same items in combo1
Public l As Boolean 'to make sure there are not same items in list1
Private Sub Command1_Click()
Call chklst(List1, Combo1.text)
Call chkcmb(Combo1, Combo1.text)
If l = True Then
If c = True Then
If Combo1.text = "" Then
MsgBox "Please enter one item", vbOKOnly, "Error" 'give a error messagebox
Exit Sub
End If
With Combo1 'add items in combo1
.AddItem Combo1.text
End With
End If
With List1 'add items in list1 and refresh the totalcount in text1
.AddItem Combo1.text
End With
Text1.text = List1.ListCount
End If
End Sub
Private Sub Command2_Click()
If List1.ListCount = 0 Then
MsgBox "No item", vbOKOnly, "error" 'give a error messagebox
Exit Sub
End If
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
With List1 'delete items and refresh the totalcount in text1
If List1.ListIndex = -1 Then
MsgBox "select one item", vbOKOnly, "error" 'give a error messagebox
Exit Sub
End If
List1.RemoveItem List1.ListIndex 'delete items
End With
Text1.text = List1.ListIndex 'refresh the totalcount in text1
Exit Sub
End If
Next
MsgBox "select one item", vbOKOnly, "error" 'give a error messagebox
Exit Sub
End Sub
Private Sub Command3_Click()
List1.Clear
Text1.text = 0
End Sub
Private Sub Command5_Click()
End
End Sub
'************************************************************
'******Initialize
'************************************************************
Private Sub Form_Load()
With List1
.AddItem "course1"
.AddItem "course2"
.AddItem "course3"
.AddItem "course4"
End With
Command1.Caption = "add"
Command2.Caption = "delete"
Command3.Caption = "clear"
Command4.Caption = "hide"
Command5.Caption = "end"
Label1.Caption = "total count"
Text1.text = List1.ListCount
End Sub
'************************************************
'** to make sure there are not same items in combo1
'** true:there are not same items
'** false:there are same items
'************************************************
Public Function chkcmb(combobox As combobox, text As String)
If Combo1.ListCount = 0 Then
c = True
Exit Function
End If
For i = 0 To Combo1.ListCount - 1
If Combo1.List(i) = text Then
c = False 'there are same items
Exit Function
End If
Next
c = True 'there are no same items
End Function
'**********************************************
'** to make sure there are not same items in list1
'** true:there are not some items
'** false:there are same items
'**********************************************
Public Function chklst(listbox As listbox, text As String)
If List1.ListCount = 0 Then
l = True
Exit Function
End If
For i = 0 To List1.ListCount - 1
If List1.List(i) = text Then
l = False 'there are same items
Exit Function
End If
Next
l = True 'there are no same items
End Function
最后声明一点,不是为了要你的分,我玩c++头痛,想休息下,哈哈。
小妹妹,问题很简单,就是繁琐,10分太少了,因为太浪费时间!!
Private Sub Command1_Click()
List1.AddItem Combo1.Text
Text1 = List1.ListCount
End Sub
Private Sub Command2_Click()
If List1.ListIndex = -1 Then Exit Sub
List1.RemoveItem List1.ListIndex
Text1 = List1.ListCount
End Sub
Private Sub Command3_Click()
List1.Clear
End Sub
Private Sub Command4_Click()
'不写了,按照你的代码就行了
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
第4个按钮,就是切换list的可见状态用的!!
看书,看书,再难的知识点书上都会有,包括参考书,建议看清华出版社的,比较精髓
我对这些一窍不通