在第一个text的keypress事件里面
判断KeyAscii是否vbKeyReturn
写检索用户名的sql语句
然后输出到第二个text就行了
判断KeyAscii是否vbKeyReturn
写检索用户名的sql语句
然后输出到第二个text就行了
解决方案 »
- 如何通过线程ID取得进程ID呢?
- 紧急求助:关于COMBOBOX,TEXTBOX与MSHFLEXGRID表格结合使用
- 为什么没有人给我分,我回答了好多问题的,郁闷。
- 转换问题 ————怪
- VB ,现有一个EXCEL模板文件,用代码实现创建一个excel文档,内容是复制模板的。格式不变,如何实现
- ADO 出错
- 怎么可以把一个软件像加壳一样放进自己的软件中呢?????
- 如何往一个程序中添加插件
- 大家能否帮着写一段代码,是这样的打击都知道应用软件里的打开选项吧,点击“打开"后不是出来一个对话框嘛?那个对话框可以显示出后缀为bmp,wav等的文件,当然了点击该文件后,文件可以打开,大家费心看看
- ImageWorkshop,完整的图像编辑器源码(绝对商业)
- SendKeys可不可以模拟键盘事件?
- OfficeXPmenu的问题。
然后
"select username from table where userid='"&txtuserid.text&"'"
if not adors.eof then
txtusername.text=adors("username")
else
msgbox ....
end if
输入id时动态搜索用户名combo即可。
Private Declare Function SendMessage Lib _
"user32" Alias "SendMessageA" (ByVal hWnd _
As Long, ByVal wMsg As Long, ByVal wParam _
As Long, lParam As Any) As Long
Private Const CB_FINDSTRING = &H14Cprivate sub form1_load()
dim cnn as adodb.connection, rs as adodb.recordset
set cnn = new adodb.connection
cnn.open yourcnnstring
set rs = new adodb.recordset
set rs = cnn.execute("select * form Password")
comboID.style = 0
comboName.style = 2
do until rs.eof
comboid.additem rs!id
comboname.additem rs!name
rs.movenext
loop
end subPrivate Sub ComboID_KeyPress(KeyAscii As Integer)
Call ComboIncrementalSearch(ComboID, KeyAscii)
comboName.listindex = comboID.listindex
End SubPublic Sub ComboIncrementalSearch(cbo As _
ComboBox, KeyAscii As Integer)
Static dTimerLast As Double
Static sSearch As String
Static hWndLast As Long
Dim nRet As Long
Const MAX_KEYPRESS_TIME = 0.5
' Weed out characters that are not scanned
If (KeyAscii < 32 Or KeyAscii > 127) _
Then Exit Sub
If (Timer - dTimerLast) < _
MAX_KEYPRESS_TIME And hWndLast = _
cbo.hWnd Then
sSearch = sSearch & Chr$(KeyAscii)
Else
sSearch = Chr$(KeyAscii)
hWndLast = cbo.hWnd
End If
' Search the combo box
nRet = SendMessage(cbo.hWnd, _
CB_FINDSTRING, -1, ByVal sSearch)
If nRet >= 0 Then
cbo.ListIndex = nRet
End If
KeyAscii = 0
dTimerLast = Timer
End Sub
end sub