Home > Net >  Perform a repeatable operation on StringBuilder when button pressed
Perform a repeatable operation on StringBuilder when button pressed

Time:02-10

I have a StringBulder strB = "123456"; and when a numerical button is pressed, i want the method to:

  1. Delete first char from strB (should be "23456")
  2. Append value from the button on the right side (e.g. "1", so "234561")
  3. Have the resulting value ("234561") be the strB value
  4. Have the ability to press one button after the other and it changing the strB (e.g. pressing 2,4,9 now, should result in steB = "561249") And with every one of the button presses the method would do its thing

How can I do that? I've been sitting over this for the past 3 days. Tried String, StringBuilder, StringBuffer, for loops, if, none of them i could make working beyond a first button click, please help :/

CodePudding user response:

  •  Tags:  
  • Related