Math app replacing values in text attribute instead adding digits

baljettimbaljettim Member Posts: 3

Im trying to make a math app that displays a problem and then you type in the solution using only numbers on a calculator like number pad. The issue im having is that the numbers are not being saved in the text attribute when i hit multiple number pad buttons. when i click on "1" then "2" im getting a "1" on the display then it replaces the one with a "2". but i want a "12".

im sure there is a simple solution to this, its just alluding me right now.

any help would be great

Comments

  • ArmellineArmelline Member, PRO Posts: 5,365

    You need to concatenate the values.

    Instead of doing something like this:

    Do something like this, using .. to add the new value to the end rather than replacing it:


  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Doing this the way @Armelline suggests is a great way to concatenate numerals.

    Another way is to multiply the number by 10 and then add the new input value. For example, if you were to hit the "2" button it would look something like this:

    Change Attribute: [self.Number] To: [(self.Number *10)+2]

  • baljettimbaljettim Member Posts: 3

    thanks guys, so simple and so functional, really appreciate it :)

Sign In or Register to comment.