Hi... I am fairly new to VBA programming in EXCEL. So my apologies in advance. I have a USERFORM with several CHECKBOXs and one TEXTBOX. When the user clicks a checkbox the textbox appears next to it for the user to enter dollar amounts.

I am trying to use the ENTER KEY from the TEXTBOX to set the TEXTBOX.VISABLE to FALSE. But, I cannot get it working. I have tried to use KeyPress, KeyDown, KeyUp and Exit to no avail. When I check for the KeyAscii or KeyCode it is blank. I anly see the numbers that were entered in the TEXTBOX.

Do you know how I can check for the enter key from within the TEXTBOX? Thank you in advance.

8 Years
Discussion Span
Last Post by Simon_Templar

Yes you can check just make sure that key preview property of that form will need to be enabled. if it is enabled then you will easily gate the value of the textboxes....

Private Sub TextBox1_[B]KeyPress[/B](ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        [B]If e.KeyChar = Chr(13) Then TextBox1.Visible = False[/B]
    End Sub
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.