473,960 Members | 27,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET: backspace button code?

4 New Member
hello.

i have written a calculator program in VB.net as im still new and working things out i have a tiny problem. i have 10 buttons zero to nine, a decimal button, plus button, equals button, textbox display, reset button and a backspace button.

ive done everything except the backspace button. (say if i click a wrong number, i want to go back and click a different 1) but i have no idea what the code is and how i do it.

thanks, help apprechiated :)
Oct 26 '06 #1
8 42658
albertw
267 Contributor
hello.

i have written a calculator program in VB.net as im still new and working things out i have a tiny problem. i have 10 buttons zero to nine, a decimal button, plus button, equals button, textbox display, reset button and a backspace button.

ive done everything except the backspace button. (say if i click a wrong number, i want to go back and click a different 1) but i have no idea what the code is and how i do it.

thanks, help apprechiated :)
hi

backspace is same as Chr(8)
Oct 26 '06 #2
korndevil666
4 New Member
hi

backspace is same as Chr(8)

okay thanks. but what is the code for the button?, havent used chr before
Oct 26 '06 #3
albertw
267 Contributor
okay thanks. but what is the code for the button?, havent used chr before
hi
you can use the _keydown method

Expand|Select|Wrap|Line Numbers
  1. Private Sub AnObject_KeyDown(KeyCode As Integer, Shift As Integer)
  2. If KeyCode = vbKeyBack Then
  3. .. enter your code here ...
  4. End If 
  5. End Sub
  6.  
or the _keypress method

Expand|Select|Wrap|Line Numbers
  1. Private Sub AnObject_KeyPress(KeyAscii As Integer)
  2. If KeyAscii = 8 Then
  3. .. enter your code here ...
  4. End If
  5. End Sub
  6.  
Oct 26 '06 #4
korndevil666
4 New Member
hi
you can use the _keydown method

Expand|Select|Wrap|Line Numbers
  1. Private Sub AnObject_KeyDown(KeyCode As Integer, Shift As Integer)
  2. If KeyCode = vbKeyBack Then
  3. .. enter your code here ...
  4. End If 
  5. End Sub
  6.  
or the _keypress method

Expand|Select|Wrap|Line Numbers
  1. Private Sub AnObject_KeyPress(KeyAscii As Integer)
  2. If KeyAscii = 8 Then
  3. .. enter your code here ...
  4. End If
  5. End Sub
  6.  
ohh, yeah it works, thats alot for your help :)
Oct 26 '06 #5
gbubeshattur
2 New Member
Hi .. all..
i am working on login page in maa project using vb.net.
in that after enterring the username if i press the enter i need that control should pass to the submit buton ..can any one give me the code plz
thanks in advance
tq
Jan 3 '07 #6
salgaonkarayush
2 New Member
Private Sub txtUser_KeyPres s(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 122 Then
txtUser.Text = ""
MsgBox "Enter only alphabets", vbOKOnly
KeyAscii = 8
ElseIf KeyAscii = 58 Or KeyAscii = 63 Or KeyAscii = 59 Or KeyAscii = 60 Or KeyAscii = 61 Or KeyAscii = 62 Then
txtUser.Text = ""
MsgBox "Enter only alphabets", vbOKOnly
KeyAscii = 8
End If
i want 2 make my backspace key work normally wat code should i modify or any better way 2 proceed
Aug 15 '07 #7
salgaonkarayush
2 New Member
can u reply the inner code 4 this 2
Private Sub AnObject_KeyPre ss(KeyAscii As Integer)
If KeyAscii = 8 Then
.. enter your code here ...
End If
End Sub
Aug 15 '07 #8
hectorhoney
1 New Member
@korndevil666
hi i am reading your problem ........
you can make one button in the code view and change name=bbackspace then its text property backspace.in property window.....now clicked backspace button
AND USE FOLLOWING CODE
Private Sub bbackspace_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles bbackspace.Clic k
Dim d As New Integer

If (TextBox1.Text. Length > 0) Then
d = TextBox1.Text.L ength
TextBox1.Text = TextBox1.Text.R emove(d - 1, 1)




End If





End Sub
Jul 10 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2568
by: gal20 | last post by:
In my login page I have 2 textbox and one submit button. I also have a keypad for users to enter text to the textbox. I need the coding for backspace button that can be used for both textbox. The one I found can only be used for one textbox. Is there any way to find the cursor position and how do I do that? Thanx in advance
1
2393
by: ACaunter | last post by:
Hi, I was wondering if there was asp.net webform (serverside) code which will refresh the page. I get a download dialog box that keeps poppin up everytime i click on any buttons on my page and i get stuck there... i can only press F5 or refresh button at the top to get rid of it and let me go on to other pages of my site... I see a lot of Javascript code to do it but i can't seem to write javascript code behind webform controls..
7
4830
by: R.A.M. | last post by:
Hello I have a question to .NET programmers about code conversion from VB6 to C#.NET: is it possible? how much work must be performed manually? Thank you very much for your answers. /RAM/ PS. By the way, how about other languages like C++, C, Delphi, etc.?
0
1182
by: BarryM | last post by:
Hi, I have web form with 2 submit buttons. One has the PostBackUrl property set to another page, and the other has nothing and falls through to the default behaviour of posting back to it's page. If I press the the cross post button I move to the 2nd page as expected. If I then use the browser's backspace button to take me back to the page with the buttons, then press the other button, the submit action still takes me to my 2nd page.
5
1946
by: manjitsarma | last post by:
I have changed the following original vb.net window application code Public Overrides Function SetTheme(ByRef frmObj As System.Windows.Forms) As Boolean into c#.net as-
66
7515
by: Jon Skeet [C# MVP] | last post by:
I'm sure the net will be buzzing with this news fairly soon, but just in case anyone hasn't seen it yet: Microsoft are going to make the source code for the .NET framework (parts of it, including the BCL, ASP.NET and LINQ) available both for viewing and debugging into. I won't go into all the details here, as they're covered on Scott Guthrie's blog:
1
1861
by: Bully | last post by:
I want to wrap a .Net command button using COM Interop, and then use this usercontrol in VB6. Is this possible and has anybody tried it? Bully
4
3115
by: Kratos2005 | last post by:
I have a ASP.Net Page with code behined in C#. as below <body> <form id="form1" runat="server"> <table align=center > <tr> <td> <asp:Label runat=server ID="lblCustomer">Customer Name: </asp:Label> <asp:TextBox Style="color:Red" runat=server ID="txtCustomer" OnFocus="clearDefault(this)">Enter Customer Name</asp:TextBox>&nbsp&nbsp&nbsp <asp:Button runat=server ID=cmdSubmit...
0
10294
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11759
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11499
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10839
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6345
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4687
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3703
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.