Results 1 to 4 of 4

Thread: How do I manually fire Form_KeyPress()

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170

    Post

    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!!

  2. #2
    New Member
    Join Date
    Sep 1999
    Location
    Boise, ID USA
    Posts
    15

    Post

    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

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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
    [email protected]
    [email protected]
    ICQ#: 51055819


  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width