Results 1 to 4 of 4

Thread: Calculator prob

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    13

    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:
    1. Private Sub btnBkSp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBkSp.Click
    2.  
    3. txtDisplay.Text = Mid(txtDisplay.Text, 1, txtDisplay.Text.Length - 1)
    4.  
    5. End Sub

    Thanks for any help.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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:
    1. myString = myString.Substring(0, myString.Length - 1)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    13

    Re: Calculator prob

    Awesome that was exactly what I was looking for, thanks for the speedy response jmcilhinney.

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    13

    Talking Re: Calculator prob

    , :d

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width