作者keria (住左住右超好看)
看板Visual_Basic
标题Re: [VB6 ] combo 如何在输入期间同时饰选资料?
时间Mon Aug 7 22:24:06 2006
※ 引述《Hotan (昊天)》之铭言:
: 如题,每输入一个字就更新一次combo里符合的内容
: Private Sub Combo2_Change()
: CN.Open ConnString
: sql = "SELECT * FROM customer "
: sql = sql & "WHERE customer_No is not null"
: If (Combo2.Text <> "") Then sql = sql & " and customer_Name = '" & Combo2.
: Text & "%' "
: combo2.clear
: ^^^^^^^^^^^^
: '这个清除找不到正确的位置..@@ 输入完也清除了,查也没查,不能放在change里?
: '请问我遗落了什麽吗?? 希望能得到前辈们的指教,怎样可以做到?? 谢谢 ^^
: RS.Open sql, ConnString, , , adCmdText
: While RS.EOF = False
: Combo2.AddItem RS("customer_Name")
: RS.MoveNext
: Wend
: CN.Close
: RS.Close
: End Sub
感觉好像是错在SQL的语法~~~@@a
刚刚我测试了一下是可以的~~~
以下是我的部份程式码,查询对象是MS-SQL的北风资料库~~~
如有其他错误,万请指教~~~:)
Private Sub Combo1_Change()
Dim Length As Integer
Set objRst = New ADODB.Recordset
strRst = "Select * From Customers Where CustomerID like '" & Combo1.Text &
"%'"
objRst.CursorLocation = adUseClient
objRst.Open strRst, objConn, adOpenStatic, adLockPessimistic
If objRst.RecordCount > 0 Then
Length = Len(Combo1)
Combo1.Clear
While Not objRst.EOF
Combo1.AddItem objRst.Fields("CustomerID")
objRst.MoveNext
Wend
End If
Combo1.ListIndex = 0
Combo1.SelStart = Length
Combo1.SelLength = Len(Combo1)
objRst.Close
Set objRst = Nothing
End Sub
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.160.63.39