vb set focus

来源:百度知道 编辑:UC知道 时间:2024/06/07 13:32:39
比如在输入了一个text1,如何自动转到text2的输入,应该有代码,请各位告诉小弟,我是一个初手。

Private Sub Text1_Change()
If Len(Text1.Text) = 2 Then'这句话的意思是当text1中的字符串长度等于2的时候就把焦点转到text2,你也可以设置别的。
Text2.SetFocus
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Text2.SetFocus '回车后转到text2
End Sub

按题目描述,乱石回答正确,按实际应用,是liss1945 说对了

Private Sub Form_GotFocus()
Text1.Text = Text1.SetFocus
End Sub

if keyascc=13 then text2.setfocus