Dim i As Integer For i = 0 To url.ListCount - 1 If url.List(i) = url.Text Then Exit Sub Else url.AddItem url End If Next 我是这样写的,但是就是不成功`
Private Function Exists(objCmb As ComboBox, ByVal strTmp As String) As Boolean Exists = False Dim i As Long For i = 0 To objCmb.ListCount - 1 If objCmb.List(i) = strTmp Then Exists = True Exit For End If Next End Function调用方法: 假设你要把Text1的内容往url(ComboBox)里添加 If Not Exists(url,Text1.Text) Then url.AddItem Text1.Text
For i = 0 To url.ListCount - 1
If url.List(i) = url.Text Then Exit Sub
Else
url.AddItem url
End If
Next
我是这样写的,但是就是不成功`
Exists = False
Dim i As Long
For i = 0 To objCmb.ListCount - 1
If objCmb.List(i) = strTmp Then
Exists = True
Exit For
End If
Next
End Function调用方法:
假设你要把Text1的内容往url(ComboBox)里添加
If Not Exists(url,Text1.Text) Then url.AddItem Text1.Text