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!

Emulation of buttons pressed

Status
Not open for further replies.

Jeka

Programmer
Nov 10, 2001
2
IL
Hello! I need to write a project - Calculator.
I want that when I press on number key on keyboard I could
see that button on the screen with the same number will pressed too.
I want that my calculator will work just as like as Windows calculator.
So is there somebody that can help me please :-(
 
Set Keypreview for the the form to true. If you have an array of 10 buttons called Command1 and a label called Label1, then in Form_keypress do
If IsNumeric(Chr$(KeyAscii)) Then
Call Command1_Click(Chr$(KeyAscii))
End If
In Command1_Click do
Label1.Caption = Label1.Caption & " " & Index

This will sort of work. If the label is a text box, you will need to be careful to stop the form picking up the keystrokes as well as the text box.
Peter Meachem
peter@accuflight.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top