Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2004
    Posts
    6

    Unanswered: Disabling/Enabling Text Boxes

    Hello,
    I'm currently working a project in VB that needs to have two text boxes disabled once data has been entered into them and then enabled when a button is clicked.

    I'm clear on how to enable the text boxes but my question is:
    How can I disable the text boses once the data is entered without clicking a button?

    Any and all help is appreciated!

    Thanks,
    Jared

  2. #2
    Join Date
    Nov 2003
    Location
    Phoenix,AZ
    Posts
    5

    Angry Enable/disable text boxes

    Quote Originally Posted by JFrey
    Hello,
    I'm currently working a project in VB that needs to have two text boxes disabled once data has been entered into them and then enabled when a button is clicked.

    I'm clear on how to enable the text boxes but my question is:
    How can I disable the text boses once the data is entered without clicking a button?

    Any and all help is appreciated!

    Thanks,
    Jared
    Actually what you are trying to do is pretty simple. I would enter code in the textbox's lost focus event that look's something like: texbox1.enable = false. Then in your button's click event, set the texbox enable property to true. You will also want to enable the text box in your form load event and after you do something with the data (like when you write the data to a database or file).

  3. #3
    Join Date
    Nov 2004
    Posts
    6
    Thanks for your help.
    At the risk of sounding like an idiot, could you tell me where the text box lost focus event is how to change to change the form load event.

    I'm somewhat new to using VB so I'm not up on all the various ways to do these things.

    Thanks.

  4. #4
    Join Date
    Feb 2004
    Posts
    59

    quick answer

    perhaps a lock/unlock code might work better...

    you can set the locked control to true on page load, and false on button_click.

    that way, the users cant enter any data when its locked, but after button click they can.

    best of luck, feel free to re-post if necessary
    -Matt H-
    www.comperfection.com

  5. #5
    Join Date
    Nov 2004
    Posts
    6
    Well, that might work.
    Actually, the users need to be able to enter the data and then the text boxes need to be disabled, when the button is clicked, the text boxes should be enabled again.

    I'm just not sure how to disable the text boxes without tying it to a click procedure.

  6. #6
    Join Date
    May 2004
    Posts
    97
    Quote Originally Posted by JFrey
    Well, that might work.
    I'm just not sure how to disable the text boxes without tying it to a click procedure.
    He gave it to you. Put the disable function in the LostFocus event of the text box. The problem you will have is that in event driven programming such as this the user is not required to leave the text box for the data to be considered set in the value of the control.

    For example: (txtLast is a textbox control, cmdNew is a command button)

    Private Sub txtLast_LostFocus(Index As Integer)
    txtLast.enabled = False
    End Sub


    Private Sub cmdNew_Click()
    txtLast.enabled = True
    txtFirst.enabled = True
    End Sub


    As soon as the user 'leaves' the txtLast textbox it becomes disabled. It can only be enabled by clicking the cmdNew command button.

    You could do the same thing with the change event, but ONLY if the data being entered is a fixed, known, length. But it's really nasty to use that.

Posting Permissions

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