Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21856

(VB6) GetKeystate & Getasynckeystate + timer = mess

$
0
0
Hello,
First of all , ill let u know that english is NOT my first language.
Okay , My problem is:
Im trying to make somekind of timer.... and this timer job is to Tell me when the B key is down
Then i came up with those code
Code:


-------------------------------------------------------------------------------------
'In a module
Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

'In a timer
Private Sub Timer2_Timer()
 
      If GetAsyncKeyState(66) Then
        msgbox "B"
      End If
     
End If
End Sub

-------------------------------------------------------------------------------------

My problem is, when i click the B button, my timer (interval 1) is flooding me with those Msgbox, while the key was only pressed one time
I added the GetKeyState API because im pretty sure im going to need it... ive tryed multiple things , without success :S

... Wow my english is so lame...
im waiting for ur answer ! thanks

Viewing all articles
Browse latest Browse all 21856

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>