+ Reply to Thread
Results 1 to 4 of 4

Detecting change in a textbox

  1. #1
    Registered User
    Join Date
    04-28-2009
    Location
    UK
    MS-Off Ver
    Excel 2000
    Posts
    38

    Detecting change in a textbox

    Up to now I've been detecting when a textbox value changes by subroutines like this
    Please Login or Register  to view this content.
    But now I've learnt to restrict users to entering integers only, using
    Please Login or Register  to view this content.
    Now, if I just use the second of these, it detects when user enters numbers, but not when user deletes something. If I use both the routines, then pressing alphabetic keys makes the system think that tbox.value has changed, when it hasn't. What I want is to detect when the text changes, or to detect keypresses for delete and backspace as well as numbers, but to ignore keypresses for the characters that don't do anything because of the second subroutine above.

    Basically, I don't really understand how to use these keyup and keypress subroutines. Any help would be appreciated.

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,669

    Re: Detecting change in a textbox

    The simple approach would be to just validate the content on exit.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    04-28-2009
    Location
    UK
    MS-Off Ver
    Excel 2000
    Posts
    38

    Re: Detecting change in a textbox

    Quote Originally Posted by shg View Post
    The simple approach would be to just validate the content on exit.
    Yes, I suppose I could use IsNumeric(tbox.text) after the event. Not quite as elegant as preventing the user from inserting alphabetic characters in the first place, but perhaps more transparent to the user. Thanks.

  4. #4
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,669

    Re: Detecting change in a textbox

    Less annoying to users as well.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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