+ Reply to Thread
Results 1 to 7 of 7

User Form TextBox Events

  1. #1
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    User Form TextBox Events

    Hi folks,

    I need some advice on coding a Textbox event.

    I have a UserForm that utilizes the Change event of a Textbox.

    The form goes through some validating before any calculations happen.

    My problem is if the user wishes to backspace, clear or perform any changes to this textbox, it bugs out.

    Here's the code:
    Please Login or Register  to view this content.
    I'm sure it's easy to fix but I've painted myself into a corner on this one.

    I've included the file for reference

    Thanks!

    Mark
    Attached Files Attached Files
    Last edited by max57; 02-22-2010 at 02:08 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,980

    Re: User Form TextBox Events

    Do you really need the calculations to be updated for each keypress? Assuming not, I suggest you use the Exit event instead.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: User Form TextBox Events

    In this case, I felt it would be less work for the user. If they wanted to change the value, then it would recalculate right away.

    The only other solution I can see it to add a "calculate" command button, but this adds one more step to the process. Trivial, but annoying if you want to change the measurements a few times and are performing twice as many steps.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,980

    Re: User Form TextBox Events

    If you really want the Change event, then you should add a check to ensure that the Textbox actually contains data (which presumably should be numeric too).

  5. #5
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: User Form TextBox Events

    Thanks

    I'll give it a try.

  6. #6
    Valued Forum Contributor
    Join Date
    08-23-2009
    Location
    Hampshire, UK
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    328

    Re: User Form TextBox Events

    Add "On Error Resume Next" to your ConvertCalc1 sub and it should allow users to delete values without a problem.

  7. #7
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: User Form TextBox Events

    Huron,

    Thanks! It did the trick.

    romperstomper: I will definitely give the check a try and get back to you.

    Thanks again.

    Mark

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1