Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace RekenmachineProject
- {
- public partial class Form1 : Form
- {
- //variabelen
- string input;
- string som1 = string.Empty; //Eerste input
- char inputTekens; //Input tekens
- string som2 = string.Empty; //Tweede input
- double result; //Result
- double numb1;
- double numb2;
- //form
- public Form1()
- {
- InitializeComponent();
- }
- //cijfer intoetsen
- private void allButton_Click(object sender, EventArgs e)
- {
- input += (sender as Button).Text;
- textBoxDisplay.Text = input;
- }
- //plus, min, keer, gedeeld door intoetsen
- private void buttonPlus_Click(object sender, EventArgs e)
- {
- inputTekens = '+';
- som1 = input;
- input = string.Empty;
- }
- private void buttonMin_Click(object sender, EventArgs e)
- {
- inputTekens = '-';
- som1 = input;
- input = string.Empty;
- }
- private void buttonKeer_Click(object sender, EventArgs e)
- {
- inputTekens = '*';
- som1 = input;
- input = string.Empty;
- }
- private void buttonDelen_Click(object sender, EventArgs e)
- {
- inputTekens = ':';
- som1 = input;
- input = string.Empty;
- }
- //Oplossing
- private void buttonOplossing_Click(object sender, EventArgs e)
- {
- som2 = input;
- double.TryParse(som1, out numb1);
- double.TryParse(som2, out numb2);
- if (inputTekens == '+')
- {
- result = numb1 + numb2;
- textBoxDisplay.Text = result.ToString();
- }
- if (inputTekens == '-')
- {
- result = numb1 - numb2;
- textBoxDisplay.Text = result.ToString();
- }
- if (inputTekens == '*')
- {
- result = numb1 * numb2;
- textBoxDisplay.Text = result.ToString();
- }
- if (inputTekens == ':')
- {
- result = numb1 / numb2;
- textBoxDisplay.Text = result.ToString();
- }
- }
- //reset knop
- private void buttonReset_Click(object sender, EventArgs e)
- {
- this.textBoxDisplay.Text = "";
- this.input = string.Empty;
- this.som1 = string.Empty;
- this.som2 = string.Empty;
- }
- //exit knop
- private void buttonExit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement