Simple Calculator W/O Classes
Description:
Small, Light weight application which allows you to "Add, Subtract, Multiply, Divide".
My Usage: I Really Don't Know, I have made Better ones.
Required Items:
Window Form (Only 1 Form.)
3 Labels
4 Text-boxes
4 Buttons
1 Windows Form
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Dev_Pump.Text = "Made By: Dev_Pump";
Dev_Pump.ReadOnly = true;
}
private void Addition_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length == 0)
{
MessageBox.Show("You have not entered a number.");
}
else
{
//Calc values, Var
int num1;
int num2;
float Answer;
num1 = int.Parse(textBox1.Text);
num2 = int.Parse(textBox2.Text);
//Calc Add Start
Answer = num1 + num2;
textBox3.Text = Answer.ToString();
SignL.Text = "+";
ActionL.Text = "Action Used: Addition";
}
}
private void Multiply_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length == 0)
{
MessageBox.Show("You have not entered a number.");
}
else
{
//Calc values, Var
int num1;
int num2;
float Answer;
num1 = int.Parse(textBox1.Text);
num2 = int.Parse(textBox2.Text);
//Calc MultiP Start
Answer = num1 * num2;
textBox3.Text = Answer.ToString();
SignL.Text = "X";
ActionL.Text = "Action Used: Multiplcation";
}
}
private void Subtract_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length == 0)
{
MessageBox.Show("You have not entered a number.");
}
else
{
//Calc values, Var
int num1;
int num2;
float Answer;
num1 = int.Parse(textBox1.Text);
num2 = int.Parse(textBox2.Text);
//Calc SubT Start
Answer = num1 - num2;
textBox3.Text = Answer.ToString();
SignL.Text = "-";
ActionL.Text = "Action Used: Subtraction";
}
}
private void Divide_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length == 0)
{
MessageBox.Show("You have not entered a number.");
}
if (textBox1.Text.StartsWith ("0"))
{
MessageBox.Show("WTF?.");
}
if (textBox2.Text.StartsWith("0"))
{
MessageBox.Show("WTF?.");
}
else
{
//Calc values, Var
int num1;
int num2;
float Answer;
num1 = int.Parse(textBox1.Text);
num2 = int.Parse(textBox2.Text);
//Calc SubT Start
Answer = num1 / num2;
textBox3.Text = Answer.ToString();
SignL.Text = "/";
ActionL.Text = "Action Used: Division";
}
}
private void TBox1(object sender, EventArgs e)
{
textBox1.Text = " ";
}
private void TBox2(object sender, EventArgs e)
{
textBox2.Text = " ";
}
}
}
Virus Total ScanOh okay. Thanks though. If you find out, post please.
The partial keyword is used when the definition of a class is split over multiple source files. So basically then when you compile it, it combines all the different pieces of the class.
you are completly off-topic. chat with pm