+ Reply to Thread
Results 1 to 3 of 3

How to allow TextBox backspace key?

  1. #1
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    803

    How to allow TextBox backspace key?

    If there are multiple characters in the textbox, there is no problem to use backspace. But if there is only one character left in the textbox, it pops up Run-time error 5 when entering backspace key. The main problem is if user enter first invalid character, he/she should be allowed to use backspace key.

    Please Login or Register  to view this content.

    Backspace.JPG

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: How to allow TextBox backspace key?

    You're trying to interpret a character that does not exist... The textbox will have been blanked before the code runs so the .TEXT property contains a null string and you cannot get the rightmost character of a null string.

    You either need to add error handling or check the textbox actually still contains something before checking the contents.

  3. #3
    Forum Contributor VAer's Avatar
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    803

    Re: How to allow TextBox backspace key?

    Quote Originally Posted by cytop View Post
    You're trying to interpret a character that does not exist... The textbox will have been blanked before the code runs so the .TEXT property contains a null string and you cannot get the rightmost character of a null string.

    You either need to add error handling or check the textbox actually still contains something before checking the contents.
    Thanks much!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to clear all text form textbox with one backspace (userform)
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2017, 12:36 PM
  2. ComboBox Backspace Strange Behaviour
    By ErrorMan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2016, 11:00 AM
  3. [SOLVED] Backspace vba code
    By emina_c in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-27-2015, 11:16 AM
  4. [SOLVED] Narrowing Results in ListBox using TextBox that Reloads when Backspace is Struck
    By kak132 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2014, 12:10 PM
  5. [SOLVED] Userform: Backspace button and Shift key
    By Gal403 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-08-2014, 03:25 AM
  6. Enable backspace key in combobox on Userform
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2011, 05:35 PM
  7. [SOLVED] Backspace and percentage, please help
    By broogle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2005, 06:06 AM

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