Guest User

Untitled

a guest
Jun 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. //Code that handles click events
  2. private void number_Click(object sender, EventArgs e)
  3. {
  4. if((txtResult.Text == "0")||(operation))
  5. {
  6. txtResult.Clear();
  7. }
  8. //Cast button to the object sender
  9. operation = false;
  10. Button button = (Button)sender;
  11. //If the button pressed is a "." then check if the txtResult already contains
  12. //a ".", if it does contain a "." then do nothing
  13. if (button.Text == ".")
  14. {
  15. if (!txtResult.Text.Contains("."))
  16. {
  17. txtResult.Text = txtResult.Text + button.Text;
  18. }
  19. }else
  20. txtResult.Text = txtResult.Text + button.Text;
  21. }
  22.  
  23.  
  24. //Keyboard press event code
  25.  
  26. private void num1_key(object sender, KeyPressEventArgs e)
  27. {
  28. if (e.KeyChar == '1')
  29. {
  30. //If keyboard '1' pressed perform number_click()
  31. btn1.PerformClick();
  32. e.Handled = true;
  33. }
  34. }
Add Comment
Please, Sign In to add comment