Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to code of remove last character of textbox using keyboard backspace key.
Posted
Updated 10-Dec-12 22:20pm
v2
Comments
Richard MacCutchan 11-Dec-12 4:20am    
Textboxes do this automatically.
AnkitGoel.com 11-Dec-12 4:30am    
As Richard said, Textboxes do this automatically. what do u want ? Please recheck and then ask.

1 solution

If you don't necessarily need to use the backspace key (simulate a key punch or how you want to call it) this will do the job of removing the last character in the textbox.
VB
TextBox1.Text = Textbox1.Text.Remove(TextBox1.Text.Count - 1)

I even tested it for ya.
You might want to add an if statement in case there is no text in the textbox (it could cause an error).
VB
If Textbox1.Text.Count > 0
TextBox1.Text = Textbox1.Text.Remove(TextBox1.Text.Count - 1)
End If

Hope this helped!
 
Share this answer
 
v2
Comments
Member 13770089 10-Apr-18 3:14am    
BUT WHAT ABOUT IF WE HAVE SO MANY TEXTBOXES

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900