• Textbox on Userform (2002/SP3)

    Author
    Topic
    #458267

    I have a number of textboxes on a user form. I want to restrict the input to this boxes to numbers from 0 to 1 (ie 0.12) or to a string of “N/A”. What procedure call should I use for such a textbox: Click, Change, KeyDown? and why?

    Viewing 0 reply threads
    Author
    Replies
    • #1151826

      I have a number of textboxes on a user form. I want to restrict the input to this boxes to numbers from 0 to 1 (ie 0.12) or to a string of “N/A”. What procedure call should I use for such a textbox: Click, Change, KeyDown? and why?

      You could use the Exit event to validate the contents. If they don’t match, pop up a message and set the Cancel argument to True.

      • #1151828

        You could use the Exit event to validate the contents. If they don’t match, pop up a message and set the Cancel argument to True.

        Can you give me an example?

        • #1151863

          I have attached an example of what I currently have. The problem I have is that when I click on the N/A checkbox I get a message that I setup in the textbox event. How can I fix this so it will work properly?

          • #1152007

            I’d add the following lines at the beginning of the Exit_txtA event procedure:

            If txtA.Value = “” Then
            Exit Sub
            End If

    Viewing 0 reply threads
    Reply To: Textbox on Userform (2002/SP3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: