Dim I as longFor I=0 To Combo.ListCount-1
    If Combo.list(I)=…… Then Combo.text=Combo.list(I)
Next I

解决方案 »

  1.   

    On Error Resume Next
    Combo1.Text = "bbb"
    If Err.Number = 383 Then
       MsgBox "无此字符串"
    Else
       MsgBox Combo1.ListIndex
    End If
      

  2.   


       Dim I   ' Declare variable.
       For I = 0 To Combo1.ListCount - 1   ' Loop through list.
          If Combo1.List(I).Text = string Then  'string 为你要比较的字符串
             Combo1.ListIndex = I
             Exit For       
          End If
       Next I
      

  3.   

    最好在combobox.text=rst("aaa")&  ""前面加一个:
    on error resume next
    以保证List中没有时能捕获错误!
      

  4.   

    '引用 Microsoft Scripting Runtime
    Dim x As New Scripting.Dictionary
    Private Sub Form_Load()
    Text1.Text = ""
    Combo1.AddItem ""
    x.Add "", Combo1.NewIndex
    Combo1.AddItem "aa"
    x.Add "aa", Combo1.NewIndex
    Combo1.AddItem "bb"
    x.Add "bb", Combo1.NewIndex
    Combo1.AddItem "cc"
    x.Add "cc", Combo1.NewIndex
    End Sub
    Private Sub Text1_LostFocus()
    Combo1.ListIndex = x.Item(VBA.Trim(Text1.Text))
    End Sub
      

  5.   

    '引用 Microsoft Scripting Runtime
    Dim x As New Scripting.Dictionary
    Private Sub Form_Load()
    Text1.Text = "aa"
    Text1.TabIndex = 0
    Combo1.AddItem ""
    x.Add "", Combo1.NewIndex
    Combo1.AddItem "aa"
    x.Add "aa", Combo1.NewIndex
    Combo1.AddItem "bb"
    x.Add "bb", Combo1.NewIndex
    Combo1.AddItem "cc"
    x.Add "cc", Combo1.NewIndex
    End Sub
    Private Sub Text1_LostFocus()
    Combo1.ListIndex = x.Item(VBA.Trim(Text1.Text))
    End Sub
      

  6.   

    Combo的查询技术 
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal 
    hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) 
    As Long
    Public Const CB_FINDSTRING = &H14CPrivate Sub Combo1_Change()
        Dim iStart As Integer
        Dim sString As String
        Static iLeftOff As Integer
        iStart = 1
        iStart = Combo1.SelStart
        If iLeftOff <> 0 Then
           Combo1.SelStart = iLeftOff
           iStart = iLeftOff
        End If
        sString = CStr(Left(Combo1.Text, iStart))
        Combo1.ListIndex = SendMessage(Combo1.hwnd,B_FINDSTRING, -1, ByVal CStr(Left( ombo1.Text, iStart)))
     
        If Combo1.ListIndex = -1 Then
           iLeftOff = Len(sString)
           combo1.Text = sString
        End If
        Combo1.SelStart = iStart
        iLeftOff = 0
    End Sub
    静态变量 iLeftOff 指定了字符长度。
      

  7.   

    combobox.text=rst("aaa")&  ""能解释一下这条语句的含义吗?小弟初学VB
      

  8.   


      你不是说来源于表吗?
    combobox.text=rs("aaa") & ""
      & "" 是为了防止NULL出错
       
      

  9.   

    那么,rst是什么意思?(很菜的问题)