现在的位置: 首页 > 综合 > 正文

Combo的自动查询技术

2013年03月18日 ⁄ 综合 ⁄ 共 593字 ⁄ 字号 评论关闭
   
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 指定了字符长度。 

 

抱歉!评论已关闭.