-
USB Button
Hey,
I'm wondering if there are any external buttons I can control with VB.NET.
I want a Ok and Cancel button that the user can physically press.
These are the only commands required to interact with the app so I want to be able to detect in VB what button is pressed.
Can anyone help me find one that works with VB?
Obviously, I need to be able to attach two to the same PC.
-
Re: USB Button
you should already have them... they're called the Enter (OK) and ESC (Cancel) keys... on the form... there is a pair of Properties: AcceptButton and CancelButton... set the AcceptButton to the OK button, and the CancelButton to the Cancel button... and you're all set.
-tg
-
Re: USB Button
I think what you're looking for is the button's click event. Either double click on the ok(or cancel) button and that will bring it up, or press F7 and in the upper left-hand corner(Should say general) chose your ok(or cancel) button and in then in the upper right-hand corner(Should say declerations) chose the click event.
-
Re: USB Button
Sorry, I think I didnt explain properly.
I want two physical buttons connected to a PC by USB or any other means.
One has the function of OK, the other of Cancel.
There is no keyboard or mouse connected to the PC, so the user can only press those two buttons.
Now what I want to know is: Where can I buy such buttons, and how can I make my app recognize which of the two button is pressed?
-
Re: USB Button
After googling a bit, I found this. Gotta say, it's something I'm kinda intrested in. The article is in c#, but there are a number of free converters. Just google C# to vb.net, and I allways use the first link that comes up.
-
Re: USB Button
The simple way is to use a USB serial port adapter. A RS-232 serial port has three inputs that can be used to monitor an external button press. Connect pin4 (DTR) to one side of a button. Connect one of the following pins to the other side of the button, pin1 (DCD), pin6 (DSR) or pin8 (CTS).
Add a SerialPort control to your program. Set the PortName and call the Open method.
The SerialPort PinChanged event is generated whenever an input line changes state, which will happen when the button is pushed or released. You can test the CDHolding, DSRHolding or CTSHolding properties (respectively for the pins used above) to determine line state.
Dick