Posted By: TheOldThing | Oct 2nd @ 12:00 PM
page 1 of 1
Comments: 1 | Views: 432
[VB6]

Okay, Basically i have created a program which works in just the same was a macro.

The application listens for a key to be pressed before it sends the text which is inside one of the text boxes on the form.

What i have been trying to do is make it so that the user can define their own button to press to send the macro

Currently it works if in the code if specify something like vbkeyF1 or vbKeyY or any vbKey code.


But when i try to put it in a variable it just gives me the run time error '13' blah blah....

I have tried using a CONST as a variable but they cannot be changed during run time and are fixed variables.


I Currently use "Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal KEY As Long) As Integer" to listen to global keypresses...


If there is an easier way of being able to listen to keypresses the way i want it please tell me Tongue Out


Thanks if anyone can help... Smiley
I'm not too sure how you're doing it, but I just set up a form with two textboxes and added this event handler:

Private Sub Text1_Change()
    If GetKeyPress(Asc(Text2.Text)) <> 0 Then
        MsgBox "It was pressed"
    End If
End Sub

I did notice that it only seems to work if I have a capital letter in Text2.

page 1 of 1
Comments: 1 | Views: 432