|
-
October 14th, 1999, 05:24 AM
#1
Option buttons
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
#2
Re: Option buttons
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
#3
Re: Option buttons
How do you capture a keyboard event ?
-
October 14th, 1999, 12:20 PM
#4
Re: Option buttons
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
-
October 14th, 1999, 01:37 PM
#5
Re: Option buttons
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|