Focus

Discussion in 'Basic4ppc Wishlist' 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

    Pascal.
     
    Last edited: Mar 21, 2008
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can use a code similar to:
    Code:
    Sub App_Start
        Form1.Show
    End Sub


    Sub TextBox1_KeyPress (key)
        
    If Asc(key) = 13 Then 
            textbox1.IgnoreKey
            button1_click
        
    End If
    End Sub

    Sub Button1_Click
        
    Msgbox(textbox1.Text)
    End Sub
    TextBox1 should be a MultiLine textbox.
     
  3. pmu5757

    pmu5757 Member Licensed User

    It works very well, thank you.
     
Loading...