Private Sub command1_click()
If Combo1.Text <> "" Then
ats = 0
For i = 0 To Combo1.ListCount - 1
If Combo1.List(i) = Combo1.Text Then
ats = 1
Exit For
End If
Next i
If ats = 0 Then
Combo1.AddItem Combo1.Text
Combo1.SelStart = 0
Combo1.SelLength = Len(Combo1.Text)
MsgBox "项目已添加"
Else
MsgBox "已在列表中"
End If
End If
End Sub
Private Sub Command1_Click()
Dim i As Integer
If Trim(Combo1.Text) = "" Then
MsgBox "不能添加空项!"
Exit Sub
End If
For i = 0 To Combo1.ListCount - 1
If Trim(Combo1.Text) = Combo1.List(i) Then
MsgBox "该项已存在!"
Exit Sub
End If
Next i
Combo1.AddItem Trim(Combo1.Text)
MsgBox "添加项成功!"
End Sub