Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending non-standard keys

Status
Not open for further replies.

DaveMere

Programmer
Nov 24, 2003
20
GB
Hello all.

Does anyone know of a way to call non-ascii keys through code? Like the "End" key for instance?

I'm trying to produce code that sends the cursor to the end of the text in a text box.

DaveMere
 
Code:
Private Sub Command1_Click()
SendKeys "{END}"
End Sub

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
You can use SendKeys to do what you have asked first, but better is to use:

Text1.SelStart = Len(Text1.Text)

and avoid using SendKeys whenever possible
 
DaveMere

The reason that CCLINT is pointing out the downfalls of using SendKeys is that your application, your form and the specific textbox all have to have focus in order for the SendKeys function to work. Obviously this causes a lot of problems making sure that they do.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
I used the .SelStart method and it works fine.

Thanks v much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top