Link to home
Start Free TrialLog in
Avatar of asns
asns

asked on

Sendkeys

Hi,

in my form there are 7 controls. how can I use Sendkeys to go through them like the Tab Key whenever i press Enter?
please give me a complete code showing the event where i use this property.

thanx
Avatar of fluglash
fluglash

Private Sub object_KeyPress([index As Integer,]keyascii As Integer)

The KeyPress event syntax has these parts:

Part Description
object --- An object expression that evaluates to an object in the Applies To list.
index --- An integer that uniquely identifies a control if it's in a control array.
keyascii --- An integer that returns a standard numeric ANSI keycode. Keyascii is passed by reference; changing it sends a different character to the object. Changing keyascii to 0 cancels the keystroke so the object receives no character.

if KeyAscii = 13 then sendkeys "{Tab}"
ASKER CERTIFIED SOLUTION
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just take in mind that it would set focus to every control in your form, not only text boxes.
Thanks for "A" grade.