Discussion in 'Questions (Windows Mobile)' started by pmu5757, Mar 21, 2008.

  1. pmu5757

    pmu5757 Member Licensed User

    Hello !
    First, excuse the poor english of a frenchy...

    I'm making a program that ask questions to the user.
    The user must type the answer in a textbox, and then click an OK button to check if the answer is right or not.
    To make the answer easier to type, I've set the focus on the answer textbox.
    But it's impossible for the user to type enter instead ok clicking ok because the focus is not on the ok button.
    Does it exist a solution to make it possible ?

    Thank you

  2. willisgt

    willisgt Active Member Licensed User

    The solution is to catch each keypress as the user types text into the box. If and when the user presses the Enter key, simply call the same subroutine that would be called if the user had clicked on the button.

    sub Textbox1_KeyPress( pKey )

    if pKey = Asc13 ) then Button1_Click   ' 13 = the Enter key, if I remember correctly

    end sub

    sub Button1_Click

    msgbox"Hello, World!" )

    end sub
    Last edited: Mar 21, 2008
  3. pmu5757

    pmu5757 Member Licensed User

    It works very well, thank you.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice