yuyake79
(yuyake79)
December 8, 2017, 1:08pm
1
Hi,
I’d like to be able to input digits to create a number of multiple digits and store its value in an integer variable using keypad widget. At the moment, I am only able to store single digit values in a variable by punching in a single number and pressing the ENTER button to store it. Please look at the pics below.
What would I need to do if I want to put in a number like 221 using the keypad and store it in a variable?
You could get the current InputPadInput multiplay it with ten and add the value of the buton and set it to be the new InputPadInput
Heidi
(Heidi)
December 8, 2017, 1:29pm
3
Make a CurrentEnteredNum variable, starting at 0.
The formular you need to use is the following:
CurrentEnteredNum = CurrentEnteredNum * 10 + NewNum.
You would input a 2 into your keypad.
CurrentEnteredNum == 0;
This would result in 0*10+2 = 2.
Now you would input another 2 into your keypad.
CurrentEnteredNum == 2;
This would result in 2*10+2 = 22
Now you enter a 1 into your keypad.
CurrentEnteredNum == 22;
This would result in 22*10+1 = 221
haha had the same idea, but you explained it more professional
yuyake79
(yuyake79)
December 8, 2017, 2:26pm
6
Thank you, too!! You had the same idea as Heidi. And you’re right! Heidi’s explanation was more professional
But, thank you