RE:Controlar SetFocus con tecla Enter
Supongamos que tienes 4 cajas de texto y un botón
Para cada caja de texto usas el evento KeyPress
Para el Text1
Private Sub Text1_KeyPress (Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 or KeyAscii=9 then
Text2.SetFocus
else
If KeyAscii=27 then
'pudieras poner que se salga del módulo
Endif
endif
End Sub
Para el Text2
Private Sub Text2_KeyPress (Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 or KeyAscii=9 then
Text3.SetFocus
else
If KeyAscii=27 then
Text1.SetFocus
Endif
endif
End Sub
Para el Text3
Private Sub Text2_KeyPress (Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 or KeyAscii=9 then
Text4.SetFocus
else
If KeyAscii=27 then
Text2.SetFocus
Endif
endif
End Sub
Para el Text4
Private Sub Text4_KeyPress (Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 or KeyAscii=9 then
Command1_Click
' para que ejecute el código de pulsar el botón.... o si acaso
' quieres mandar el foco pues pon Command1.SetFocus
else
If KeyAscii=27 then
Text3.SetFocus
Endif
endif
End Sub
Lo del 9 en la pregunta IF es para que igual te funcione el tabulador como enter... pero para esto debes de poner la propiedad TABINDEX o TABSTOP.. no me acuerdo cual era.... de todos tus componentes como FALSE
Esto último no estoy muy seguro... pero ponlo por si acaso ves que no te funciona bien...
Saludos