Intercepting the 0 key and decimal point validation in a calculator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chimok
    New Member
    • Feb 2010
    • 1

    Intercepting the 0 key and decimal point validation in a calculator

    I create a calculator in visual basic and I put button from 0 to 9 ... and event click
    textbox1.text = textbox1 + "1" (to 9) ..it work good .. but if i press key 0 from keybord nothing is hapens ....who can help me to solve this problem

    and the secoun problem .. if I put for example 3.25.89 not 3.2589 how can write in code a "if" for example if textbox1.text -alredy contain a point (.) 3.25 then I click again on button point .. it remain 3.25 but not 3.25.
  • semomaniz
    Recognized Expert New Member
    • Oct 2007
    • 210

    #2
    Please post you code and show us what you have done

    Comment

    • mshmyob
      Recognized Expert Contributor
      • Jan 2008
      • 903

      #3
      Check out my code here. It takes care of it.

      cheers,

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        If you press any key from the keyboard the user has to be in the TextBox that contains the number.

        You should probably change the TextBox into a MaskedTextBox so that the user is forced to enter a number that is in the format that you are expecting (for example they can only enter one decimal point).

        -Frinny

        Comment

        Working...