我需要将这种语言(用VB6编写)转换为VB.NET:
Private Sub txt1_KeyPress(KeyAscii as Integer)
If KeyAscii=13 Then
XXX=CStr(txt1.Text)
txt2.SetFocus
End If
End Sub
我只想按 Enter 键(KeyAscii = 13),txt1将Focus设置为下一个文本框txt2
。
有人能帮助我吗?感谢。
答案 0 :(得分:1)
试试这个:
Private Sub Txt1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles Txt1.KeyPress
If e.KeyChar.ToString = ChrW(Keys.Enter) Then
Txt2.Focus()
e.Handled = True
End If
End Sub