CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: "esc" unable

  1. #1
    Join Date
    Feb 2002
    Posts
    295

    "esc" unable

    Hi there,

    I have here a piece of code which is I don't know whats the main
    reason why the "esc" key does not function.
    I put this code in my login form. Im just wondering why the code doesn't work in my login form. I have a login form with two textfield, and a LaVolpeButton "OK" & "Cancel". Please help me figure out what happen. Is it the code? By the way here's my code.

    ===================================

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = 27 Then
    On Error Resume Next
    Unload Me

    Dim x As Integer
    x = MsgBox("Are you sure you want to Close the Application ...", vbQuestion Or vbYesNo, "Want to Close Application ..")
    If x = 6 Then
    Unload Me
    End If
    End If
    End Sub

  2. #2
    Join Date
    Apr 2002
    Posts
    388
    Set the Cancel -property of the "Cancel"-key to true and the code of the Button_Click Event is executed when ESC is pressed.

    It's simmilar to the Default -property. The code is executed if the Return key is pressed.
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

  3. #3
    Join Date
    Feb 2002
    Posts
    295
    Hi Ungi,

    Im sorry since im only new to vb please give me more idea on how to do it. Can i do it like this?

    ==============================
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer, Cancel As Integer)


    Thanks,
    Jay

  4. #4
    Join Date
    Apr 2002
    Posts
    388
    You said that you have two buttons: an OK Button and a Cancel Button.

    If you open the properties window of the Cancel button you will find a property called "Cancel" with the value false. if you set the value to true the Click event of this button will be executed everytime you press Escape. In this click event you could close the form or end the program or so.
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

  5. #5
    Join Date
    Feb 2002
    Posts
    295

    "esc" button

    Ungi,

    I don't have problem in my "Cancel" button all I need to know is why is it that during runtime when I press the "esc" button, that command doesn't work for me. But in fact in other application it works. Is it because Im using a LaVolpeButton?

    Please give me specific idea please.

    Thanks

  6. #6
    Join Date
    Apr 2002
    Posts
    388
    What exactly is a LaVolpeButton?
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)