Click to See Complete Forum and Search --> : Space bar
Greenjedi
April 25th, 2006, 03:20 AM
HI
I have a program that does something when I hit space bar, I want it to be impossible to press space again if the function is not yet ready, but I donmt want a program freeze zo I just want to temporarily disable the spacebar
kebo
April 25th, 2006, 10:08 AM
one easy method would be to use a static busy bit in the function as follows
Sub SpaceBar
static Busy as Boolean
if Busy then
Exit Sub
Else
Busy = True
....blah
.....blah
...your code goes here
....blah
Busy = False
Endif
End Sub
HTH
kevin
Rich2189
April 25th, 2006, 11:56 AM
Using exit sub makes the code hard to read this would be better
Sub SpaceBar
static Busy as Boolean
if not Busy then
Busy = True
'do your stuff
Busy = False
End if
end sub
kebo
April 25th, 2006, 12:51 PM
Using exit sub makes the code hard to read this would be better
cheers :thumb:
Rich2189
April 25th, 2006, 03:59 PM
cheers :thumb:
No Problem, sorry im really pedantic about having neat readable code :)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.