PaulS:
Why would you support entering non-digits, when you only care about some of the digits?How is the keypad going to return a B?
You need to have a key on the keypad mean "the complete value has been entered; convert the string to a value, and store that value". It is then easy to count the number of times that key is pressed, to know what to do with the value (that is, where to store the value).
How many keys on your keypad? Aside from the 0 to 9, what meaning have you assigned to the other keys?
How will you deal with fat-fingering? I can hardly hammer 3 keys in a row without reaching for the backspace key. Are your users better typists than me? Not that that would be even remotely hard, but you should have a way of dealing with mistakes.
keypad has characters A,B,C,D,,# out of which i have already used A,,# for other purposes.* key promts the user to enter again.and yes I have figured out how to do it ,but am not getting the results of codes I have tried .