-
I try to close my App with the Escape Key, but is'nt working .....
I do this in a Module:
Option Explicit
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public Const VK_ESCAPE = &H1B
Sub Main()
Load frmMainX
frmMainX.Show
Load frmMainY
frmMainY.Show
If GetAsyncKeyState(VK_ESCAPE) <> 0 Then
Unload frmMainX
Unload frmMainX
End If
End Sub
May someone could tell me what i do wrong?
Thx,
Susn
-
This is wrong:
If GetAsyncKeyState(VK_ESCAPE) <> 0 Then
This is right:
If GetAsyncKeyState(VK_ESCAPE) Then
-
ESCAPE
-
Or you can do the following, since it returns True on success.
Code:
GetAsyncKeyState(VK_ESCAPE) = 1
-
Quote:
Originally posted by Megatron
Or you can do the following, since it returns True on success.
Code:
GetAsyncKeyState(VK_ESCAPE) = 1
By default, it's already 1-True.
-
. But doesn't she need some kind of loop?
I didn't see any problem with the way she was using the command, though i would have used " = 1 " myself.
The problem with her code is she only checked for the escape key one time. When the program was loaded.
-
ESCAPE
HELLO!
You are right, Lord Orwell ....
Further checking the Status of Escape Key in the Timer Event .....
-
heh, the users of this board see so many incorrect api calls, etc. causing bugs, that sometimes we forget to look for simple logic problems in the design... :p
-
VK_ESCAPE = &H1B
May she only needed the Syntax of this call ....
Possible that only was an Example.