+ Reply to Thread
Results 1 to 5 of 5

Backspace event text box string formatting not able to delete characters

  1. #1
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Backspace event text box string formatting not able to delete characters

    I'm trying to make a user form for data entry and I have a textbox with tariff codes. the layout is ####.##.##.## which the macro works well at formatting. problem is when you try to backspace you cannot go past any of the periods. I tried to trap a backspace event as a condition for not putting the period but it does not seem to work. also I tried to prevent the user from entering their own periods and that isn't working either.

    any help would be much appreciated.

    Thanks,

    Chris


    Please Login or Register  to view this content.
    Last edited by Code Flunkie; 05-28-2014 at 04:30 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Backspace event text box string formatting not able to delete characters

    KeyAscii will always be 0 as it's never given a value in the code.

    Perhaps you are using the wrong event?

    Textboxes have events, eg KeyPress, that are passed KeyAscii representing the key pressed.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: Backspace event text box string formatting not able to delete characters

    I understand what you are saying but i'm lost as how to translate that in to code.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Backspace event text box string formatting not able to delete characters

    Well the code would probably be pretty similar to, if not exactly the same as, the code you already have, it would just be triggered by the KeyPress event rather than the change event.

  5. #5
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: Backspace event text box string formatting not able to delete characters

    awesome, it works perfectly, thanks for the help.

+ 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. delete last 5 characters from string
    By leooconnor in forum Excel General
    Replies: 6
    Last Post: 01-02-2015, 08:50 PM
  2. Replies: 4
    Last Post: 12-08-2010, 01:28 PM
  3. Register backspace within a combobox change event
    By Newbie_Nick in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2010, 07:24 AM
  4. Assigning backspace and delete to form buttons
    By solnajeff in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-03-2010, 09:32 AM
  5. Replies: 5
    Last Post: 05-15-2006, 01:15 PM

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