Results 1 to 10 of 10

Thread: Key Press "Confusion"

  1. #1

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    I noticed in the menu editor that it doesn't allow for esc, page up, or page down to be a short cut?? Is there a way around this?? I know i can use the KeyPress event, but I'm not sure where to put the code?? i just want to enable the user to push escape anytime during the program, and for the program to terminate.. thanks you

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    Set the Form's KeyPreview Property to True

    Then add this code:
    Code:
    Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyEscape Then
        'code to termanate(unload all forms)
    End If
    End Sub
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    how about using vbKeyEsc that works... sometimes... try it at least...

    give it a shot
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  4. #4
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    whooops!
    I guess gwdash already answered... thnx
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  5. #5
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    u might wanna replace:
    'code to termanate(unload all forms)
    with:
    End
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  6. #6
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    MoMad:

    Using End on this board is sacreligious!
    Donald Sy - VB (ab)user

  7. #7
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    That's why i said it the way i did, i don't want to start a Holy War!!!!!
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  8. #8
    Guest
    END should never be used by itself.

    Use this code to end your program:

    Code:
    Public Sub UnloadAllForms()
    Dim Form As Form
    For Each Form In Forms
    Unload Form
    Set Form = Nothing
    Next Form
    End Sub
    
    Usage
    
    UnloadAllForms
    And in your menus, if you want to emulate a shortcut key, like that space between the words and a shortcut:

    Code:
    mnuExit.Caption = "&Exit" & Chr$(9) & "Esc"

  9. #9

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496

    ..

    Thanks everyone for the responses, it's been while since i have programmed in vb, i understand everything about what mathew gates said, but what does the set form = nothing do?? thanks

  10. #10
    Guest
    It will free up any resources that your form is using from memory .

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