[VB6]Using virtual key codes
by pH on Feb.26, 2010, under Articles by pH, Computer Programming / Scripting, Visual Basic 6
I’m surprised I hadn’t already posted this, so I thought I would as it’s extremely useful.
Here is a module for vb6, import it using vb6 by hitting “Project” (up the top) followed by “add module”, then click existing and browse to the location of the extracted .bas file.
Here’s an example of how to use it in your project:
if GetAsyncKeyState (112) < 0 then
call DoStuff()
end if
This will trigger the events of the DoStuff sub when the user presses F1.
To get a list of key codes visit this link and convert them to decimal.
(To do this in ms calc click view up the top > scientific and then click the hex radio button, paste the number from the MSDN page and then click dec. The resulting number is the one you use in VB6.)
Good luck!