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!

How do I highlight all info in a text box when Shift + Tab is pressed?

Status
Not open for further replies.

yryan

Programmer
May 10, 2002
15
CA
This is the last of my questions for today. I know that I've seen the code for this somewhere but I don't remember where. Is there a quick and easy way to do this? [dazed]
 
You select all the text in a text box with

Text1.selstart = 0
text1.sellength = len(text1.text)

Put this in the on of the Key events (Down or Press, can't remember which, the one with Key as a parameter)

and then

If Key = vbKeyTab then
Text1.selstart = 0
text1.sellength = len(text1.text)
end if

But thats not quite it.

I can't remember if there is another parameter for whether the Shift key is pressed or not, I think I did it by havig a module scoped boolean storing if the shift key has been pressed, and then the next time round it checks for the tab key aswell.

Of course, you must set TabStop = FALSE on ALL the controls on the form, and write code to stop VB from automatically switching them back on (which it will)

Of course, if you WANT the tabstops to work AS WELL, you'll have to write in your own code to do that on the rest of the control 'cos you had to switch them all off.

To summarize

Its loads of work, do something else if you can ;)

Jim.

not much help, but it may point you in the right direction.
 
Why couldn't you just let the user push Ctrl + A. Doesn't that work. I know that is default for "Select All" in most other programs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top