|
-
Dec 16th, 2006, 08:24 PM
#1
Thread Starter
New Member
Calculator prob
I have been building a calculator and I am having a problem with my back space button, it removes a number from the textBox, but as soon as I enter another number it lists all the numers I have pressed, it is still storing all the numbers???
How do I remove the numbers from the total as well as the textBox?, here's the code for my remove button:
VB Code:
Private Sub btnBkSp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBkSp.Click
txtDisplay.Text = Mid(txtDisplay.Text, 1, txtDisplay.Text.Length - 1)
End Sub
Thanks for any help.
-
Dec 16th, 2006, 08:29 PM
#2
Re: Calculator prob
That would suggest that you're storing the entire number somewhere other than just the TextBox and you're not removing the digit from that value.
Also, if you are going to use old VB6-style functions then you should be using Left, not Mid. I would suggest using String.Substring instead though:
VB Code:
myString = myString.Substring(0, myString.Length - 1)
-
Dec 16th, 2006, 08:34 PM
#3
Thread Starter
New Member
Re: Calculator prob
Awesome that was exactly what I was looking for, thanks for the speedy response jmcilhinney.
-
Dec 17th, 2006, 09:58 AM
#4
Thread Starter
New Member
Re: Calculator prob
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|