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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text highlighting

Status
Not open for further replies.

ggdev

Programmer
May 29, 2007
12
0
0
GB
I used to use sendkeys in VB6 on 98 & XP to highlight a text field when a user tabbed into it. Sendkeys no longer seems to work on Vista and despite experimenting with SendInput, I have not been able to batch keystrokes together. I wish to send SHIFT+END together!
Does anyone know of a method to automatically highlight a text field when a user tabs into it on Vista (running a VB6 app)?
Thanks.
 

Have you tried old fashioned;
Code:
Private Sub Text1_GotFocus()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub

Have fun.

---- Andy
 
No - I'd got carried away with looking for a more complex solution!
Thanks very much. That does exactly what I need.
 
>Sendkeys no longer seems to work on Vista

Erm ... I thought they'd fixed that in RC2 and later - but only in compiled apps; you get an error in the IDE (not that I'm advocating using SendKeys if it can possibly be avoided)
 
strongm - Thanks for your comments - I'll bear them in mind.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top