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

command button action

Status
Not open for further replies.

NealBrooks

Programmer
Feb 6, 2002
2
US
How do I make a command button appear depressed and released using the keyboard instead on a mouse click?
 
By "appear depressed and released" I assume you mean that you want the dotted-line
outline of the button to appear then disappear like it does when clicked on. I also assume you know how to create a hotkey for your commamnd button (place an ampersand in front of the hotkey character in the caption propery of the command button).

The button actual does appear depressed and released when using the keyboard; whether you can see this or not depends on the speed of your system.

To "slow down" your system so that the "depression and release" is visible, place this bit of code at the beginning of the Click() event for your command button. The larger number can be adjusted to give you the effect you want. Hope this helps

Dim I As Integer
For I = 1 To 10000
Next I

P.S. I'm new to VB (though not to programming), so there may very well be a specific function in VB for creating a delay. The above trick can be used in many languages, including VB. "It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
Dude. That trick has been around for ages. I was doing that little trick back in the late 80's early 90's. It worked really well with VB 3. Of course the systems back then were alot slower then they are now.
 
Thanks for the help. I did not realize the button "depress" occured but to fast to see. The pause worked. The trouble with learning from a book is the lack of personal interaction to help answer questions.
 
Glad to help. I know what you mean about learnning from a book. I'd been programming for 9 years before I communicated in any way, shape, or form with another programmer (wasn't on line back then). The learning was slow, but I did learn to dig in and experiment, and it's really helped me in learning other languages since.
The problem I see when I take courses today is that so many of the people want the instructor to lead them by the nose, step by step, through everything. At that rate it'd take you ten years to become even moderately successful in any language. You've got to experiment, try this and that, and only ask help after you've run up against the wall a half -dozen or so times on a problem. As a general rule, if I have a problem that takes me 2-3 days to figure out, I'll learn 3 or 4 new things totally unrelated to the problem I started out researching. "It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top