Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi guys i want to program a backspace function for my Scientific Calculator Project i coded something like this

private void button48_Click(object sender, EventArgs e)

{

textBox_Result.Text = textBox_Result.Text.Remove(textBox_Result.Text.Len gth - 1);

if (isOperationPerformed == true)

{

textBox_Result.Text = textBox_Result.Text;

}

else if (textBox_Result.Text == "")

{

textBox_Result.Text = "0";

}


i want this code to work only when operation is not performed but if operation performed true then it should not work but it not seems to work

What I have tried:

Tried if else type functions but that doesn't worked :(
Posted
Updated 4-Oct-17 1:49am

use SendKeys.Send Method (String) (System.Windows.Forms)[^]

private void button1_Click(object sender, EventArgs e)
       {
           textBox1.Focus();
           SendKeys.Send("{BACKSPACE}");
       }
 
Share this answer
 
Comments
Vicky Malhotra 4-Oct-17 8:12am    
Thanks but it's not that what i want :|
Vicky Malhotra 4-Oct-17 8:39am    
Here is my source code~ https://pastebin.com/USeeZXuF
If you can figure this then pls do thanks
Karthik_Mahalingam 4-Oct-17 23:39pm    
what you are trying to achieve
private void button48_Click(object sender, EventArgs e)
{
   if (isOperationPerformed == true)
   {
    // do nothing
   }
   else if (textBox_Result.Text.Length > 0)
   {
     textBox_Result.Text = textBox_Result.Text.Remove(textBox_Result.Text.Length - 1);   
   }
 
}
 
Share this answer
 
Comments
Vicky Malhotra 4-Oct-17 8:10am    
Hey thanks man it works only when i use isOperationPerforemed == false but it also works when operation is not performed i want to remove the text if operation is not performed.
Here is my source code~ https://pastebin.com/USeeZXuF
CPallini 4-Oct-17 8:52am    
And how do you tell that 'operation is not performed'?
Vicky Malhotra 4-Oct-17 8:56am    
you can see my source code: https://pastebin.com/USeeZXuF
i defined bool isOperationPerformed = false;
=|
CPallini 4-Oct-17 9:08am    
Probably I don't get you. Do you mean that nothing happens (no character removal) when (isOperationPerformed == false) ?
Vicky Malhotra 4-Oct-17 9:17am    
No :( it not removes anything when i define false and when i define true it removes even when operation is performed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900