Click to See Complete Forum and Search --> : How do I manually fire Form_KeyPress()
PhilipG
Dec 4th, 1999, 11:29 AM
Hello, I would like to call the Keypress event from within another block of code. For example:
Public Sub Test()
Call Form_KeyPress("A")
End Sub
Thanks for any info!!
SmashingPumpkinsAddict
Dec 4th, 1999, 01:19 PM
Actually, as I'm sure you know, you can't. Not like that anyway. What you need to do is create a generic sub that handles both (calls from Form_KeyPress and your other sub). For example:
Private Sub Form_KeyPress(KeyAscii As Integer)
GenericSub(KeyAscii)
End Sub
Sub AnotherSub()
GenericSub(KeyThatYouWantFired)
End Sub
Sub GenericSub(KeyThatYouWantFired as Integer)
'do whatever you are trying to do here
'such as setting properties or calling
'other subs
End Sub
-Adam
Serge
Dec 4th, 1999, 10:43 PM
Yes, you can. But you can't pass the actual letter but rather an ASCII number for that letter:
Call Form_KeyPress(Asc("A"))
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
PhilipG
Dec 5th, 1999, 01:18 AM
Thanks for your help guys!! Unfortunatly neither of those solutions solved my problem. I'm having difficulties with MSComm and this was an attempt to fix them. Please check out my question about MSComm firing.
Thanks!!
Phil
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.