October 14th, 1999, 05:24 AM
I have two option buttons, I wish to toggle between them every time the space bar is hit how is this done ?
|
Click to See Complete Forum and Search --> : Option buttons October 14th, 1999, 05:24 AM I have two option buttons, I wish to toggle between them every time the space bar is hit how is this done ? October 14th, 1999, 07:27 AM Capture the keyboard_event and if the ASCii value of the key pressed is equal to the value for space bar, enable/disable the appropriate button. October 14th, 1999, 07:59 AM How do you capture a keyboard event ? October 14th, 1999, 12:20 PM Don't know why I can't get this to work for the space bar (ascii value = 32), but it works just fine for the Enter key (ascii value = 13) and just about any other key BUT the spacebar. Private Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii = 13 And Option1.Value = True Then Option1.Value = Not Option1.Value Option2.Value = Not Option2.Value Else Option2.Value = Not Option2.Value Option1.Value = Not Option1.Value End If Vlad Chapranov October 14th, 1999, 01:37 PM First of all set KeyPreview property of form to true. Then use this code: private Sub Form_KeyDown(KeyCode as Integer, Shift as Integer) If KeyCode = 32 then KeyCode = 13 If KeyCode = 13 then If Option1 then Option2 = Not Option2 else Option1 = Not Option1 End If End If End Sub Vlad codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |