我在COMBO1控件里加了
10 北京
20 天津
30 上海
现在用户很熟悉这些代码了,用下拉条一个个找很麻烦,他们直接输入10,然后回车在COMBO1里面就出现“北京” 。 输入20在COMBO1里面就出现“天津”等字样了,如何实现?请给与帮忙。谢谢
分不够再加
10 北京
20 天津
30 上海
现在用户很熟悉这些代码了,用下拉条一个个找很麻烦,他们直接输入10,然后回车在COMBO1里面就出现“北京” 。 输入20在COMBO1里面就出现“天津”等字样了,如何实现?请给与帮忙。谢谢
分不够再加
Attribute VB_Name = "Module1"
Option ExplicitGlobal WasDelete As BooleanPublic dbfilename As StringPublic Type iSense
sOut As String * 50
End TypePublic Function IntelliSense(tBox As TextBox, AddRecord As Boolean) As String
Dim iChannel As Integer, iActive As Integer, iLength As Integer, i As Integer
Dim iFile As String
Dim iSense As iSense
Dim Done As Boolean
iFile = App.Path & "\IntelliSense\" & tBox.Name & ".dat"
iLength = Len(iSense)
iChannel = FreeFile
Open iFile For Random As iChannel Len = iLength
Close iChannel
iActive = FileLen(iFile) / iLength
iChannel = FreeFile
Open iFile For Random As iChannel Len = iLength
If AddRecord Then
iSense.sOut = tBox.Text
Put iChannel, iActive + 1, iSense
Else
Do While Not EOF(iChannel) And Done = False
i = i + 1
Get iChannel, i, iSense
If tBox.Text = Mid(RTrim(iSense.sOut), 1, Len(tBox.Text)) Then
IntelliSense = RTrim(iSense.sOut)
End If
Loop
End If
Close iChannel
End FunctionPublic Sub iSenseChange(tBox As TextBox)
Dim iStart As Integer
Dim iSense As String
iStart = tBox.SelStart
iSense = IntelliSense(tBox, False)
If iSense <> "" And Not WasDelete Then
tBox.Text = iSense
tBox.SelStart = iStart
tBox.SelLength = Len(tBox.Text) - iStart
End If
End SubPublic Sub iSenseKeyPress(tBox As TextBox, KeyAscii As Integer)
If KeyAscii = 13 And tBox.Text <> "" Then
IntelliSense tBox, True
ElseIf KeyAscii = 8 Then
WasDelete = True
Else
WasDelete = False
End If
End Sub
if keyascii=13 then
dim I as long
for I=1 to combo1.listcount-1
if left(combo1.list(i),2)=combo1.text then
combo1.text=mid(combo1.list(i),3)
endif
next I
end if'我只是提供思路,具体修改一下应该可以实现(完)
Private Sub Combo2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Dim I As Long
For I = 1 To Combo2.ListCount - 1
If Left(Combo2.List(I), 2) = Combo1.Text Then
Combo1.Text = Mid(Combo1.List(I), 4)
End If
Next I
End IfCOMBO2里有
10 北京
20 天津
我输入10然后回车没有任何反映啊
End Sub