|
-
Feb 26th, 2000, 01:56 PM
#1
Thread Starter
Member
KeyDown Event
Hi, I am writing a program using the keydown event. It works great except I can not get it to send the number keys and other keys like, space, enter, shift, etc. to my text file? Why, would it send letters and not numbers. An example of my code follows:
Code:
Private Sub Form_KeyDown(keycode As Integer, Shift As Integer)
If keycode = 54 Then
Dim ggFile As Integer
ggFile = FreeFile
Open "C:\Log.txt" For Append As ggFile
Print #ggFile, "6";
Close ggFile
End If
Also, When I make the program Invisible it will not send any keys to the file.
Thanks,
Kevin
Edited by kevdog on 02-27-2000 at 02:02 AM
-
Feb 26th, 2000, 04:51 PM
#2
Hyperactive Member
To send the all the number keys this is what I do:
Private Sub Form_KeyDown(keycode As Integer, Shift As Integer)
Dim strChr as String
strChr = KeyAscii
If strChr => 0 and strChr <= 9 then
'Dosomething
endif
end sub
-
Feb 27th, 2000, 01:59 AM
#3
Thread Starter
Member
It won't work for me, it give me a runtime error 13. This is my current code, Please Help.
Code:
Private Sub Form_KeyDown(keycode As Integer, Shift As Integer)
Dim strChr As String
strChr = KeyAscii
If strChr >= 0 And strChr <= 9 Then
Open "C:\Log.txt" For Append As strChr
Print #strChr, ;
Close strChr
End If
End Sub
Thanks,
Kevin
-
Feb 27th, 2000, 03:01 AM
#4
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|