,标题:Combo的自动查询技术" /> Combo的自动查询技术 - 关于VB的经验之谈 - VB爱好者乐园(VBGood) - 关于VB的经验,电子教程,代码,控件,论坛,博客,微博等.

VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - Combo的自动查询技术
发表评论(0)作者:, 平台:, 阅读:12024, 日期:2000-03-12
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 = &H14C

Private 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 指定了字符长度。