+ 1

c# how i can make the button clear one number or one letter without clear the all numbers in c#

25th May 2017, 2:09 PM
ALAMOUDI, WAEL MAKKI S
ALAMOUDI, WAEL MAKKI S - avatar
7 Answers
+ 2
show your code and we will try to help. with your very limited info, I would suggest on button click, take the number or string and run it thru a method to remove what you want and then return it with the new number or string
25th May 2017, 2:21 PM
LordHill
LordHill - avatar
+ 2
I see.. Assuming you know how button clicks are handled. when you click the button, take the textbox input and store it in a variable. pass this variable into a method to remove the #4 and then store your new number without the 4 in it into the variable. assign the text of your textbox to have the value of your new variable
25th May 2017, 2:46 PM
LordHill
LordHill - avatar
+ 2
Here is an example I threw together // for the example, when you click the button it would store your textbox value to a variable like static String inbox="1234"; I made a temporary variable to build the new string without the number 4 static String tempVar; //This method takes a string, such as the variable you store from your textbox, and removes the number 4 from it. static void clearStuff(String x){ foreach(char c in x){ if(c=='4'){} else{tempVar=tempVar+c;} } //instead of this method writing the new variable as I did here, change this part to assign your textbox text Console.WriteLine(tempVar); }
25th May 2017, 3:34 PM
LordHill
LordHill - avatar
+ 2
Here it is without comments if you want to copy and play with it. static String inbox="1234"; static String tempVar; static void clearStuff(String x){ foreach(char c in x){ if(c=='4'){} else{tempVar=tempVar+c;} } Console.WriteLine(tempVar); }
25th May 2017, 3:36 PM
LordHill
LordHill - avatar
+ 1
look like this I add to textbox number 1234 ok. now I want clear just number 4 number 4 just
25th May 2017, 2:40 PM
ALAMOUDI, WAEL MAKKI S
ALAMOUDI, WAEL MAKKI S - avatar