vb 焦点获取问题

来源:百度知道 编辑:UC知道 时间:2024/06/04 17:04:10
现在有两个text文本,输入一个完毕之后按回车自动跳转倒下一个text 怎么实现?谢谢!

Private Sub Text1_KeyPress(KeyAscii As Integer)
if keyascii=13 then text2.setfocus
End Sub
加上这段代码就行了。

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) '这个事件是当在Text1按下键盘所发生的事件
If KeyCode = 13 Then '如果按下的键ascii码是13(也就是回车的ASCII码
Text2.SetFocus 'setfocus 是接焦点属性
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
Text2.SetFocus
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

'13表示按的回车
If KeyAscii = 13 Then
KeyAscii = 0 '这句是防止在文本框中按回车计算机发出响声
SendKeys "{TAB}" '相当于按TAB,
End If

End Sub