for i=1 to list1.ListCount
    if list1.List(i)=要添加的数据
       msgbox "该数据已经添加"
    exit for
    end if
next

解决方案 »

  1.   

    for i=0 to combo.ListCount-1 
        if combo.text<>S then'你要加的值
            combo.additem s
        endif
    next
      

  2.   

    for i=0 to combo.ListCount-1 
        if not combo.text=你要加的值 then
            combo.additem s
        endif
    next
      

  3.   

    Private Const CB_FINDSTRING = &H14C
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Dim nIndex As Long
    Dim S As String
    S = "你需要找的字符串"
    nIndex = SendMessage(Combo1.hwnd, CB_FINDSTRING, 0, ByVal S)
    If nIndex = -1 Then
        MsgBox "没有找到!"
    Else
        MsgBox "找到了!"
    End If
      

  4.   

    dim findit as boolean
    for i=0 to combo.ListCount-1 
        if combo.text=你要加的值 then findit=true
    next
    if findit then combo.additem 你要加的值
      

  5.   

    不行啊,我每次additm以后,下次再运行,所添加的值就没有了,怎么办?
    For i = 0 To Form2.Combo1.ListCount - 1 Step 1
        If Text1.Text = Form2.Combo1.List(i) Then
            x = True
        End If
    Next
    If x = True Then
        ret = MsgBox("这个学院已经添加!", vbOKOnly, "提示")
    Else: Form2.Combo1.AddItem Text1.Text
          End If
      

  6.   

    dim findit as boolean
    for i=0 to combo1.ListCount-1 
        if combo1.text=Text1.Text  then findit=true
    next
    if findit then
        ret = MsgBox("这个学院已经添加!", vbOKOnly, "提示")
    else
        combo1.AddItem Text1.Text
    End If
      

  7.   

    如果想保存里面的数据则在添加完后将数据写入一个文件之中,如
    open "1.txt" for output as #1
    for i=0 to combo1.ListCount-1 
        print#1,combo1.list(i)
    next
    close #1
    如果是读,这样就行了
    open "1.txt" for output as #1
    combo1.clear
    Do While Not EOF(1)
       Line Input #1, a$
       combo1.additem a$
    Loop
    close #1