iccaros Posted March 7, 2006 Report Share Posted March 7, 2006 (edited) ok I am creating a calculator, and I want the decmial point to only be applyed if it is not been done already.here is my funtion. private void buttonDecimal_Click(object sender, EventArgs e) { if (decmialOn != true) { if (outPutBox.Text == "0") outPutBox.Text = "0."; else outPutBox.Text = outPutBox.Text + "."; } else decmialOn = true; outPutBox.Text = outPutBox.Text; }for information..the outPutBox is my renamig of textBox (I think I will change it to calcDisplay but have not decided.. I am horrable at creating varable names.also decmialOn is declared aspublic partial class Calc : Form { public Calc() { InitializeComponent(); } private int funtionKey = 0; private bool decmialOn = false; private double calcStorage = 0.0;the entire code (so far to date.....) form1.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Calc{ public partial class Calc : Form { public Calc() { InitializeComponent(); } private int funtionKey = 0; private bool decmialOn = false; private double calcStorage = 0.0; private void functionProcess() { //this funtion will do all processing of /*-+ //this will be a case statment that will check the value //of funtionKey 1 for addition 2 for subtract, 3 for devide, 4 for multiply double calcTemp = calcStorage; calcStorage = Convert.ToDouble(outPutBox.Text); switch (funtionKey) { case 1: outPutBox.Text = Convert.ToString(calcTemp + calcStorage); break; case 2: outPutBox.Text = Convert.ToString(calcTemp - calcStorage); break; case 3: outPutBox.Text = Convert.ToString(calcTemp * calcStorage); break; case 4: outPutBox.Text = Convert.ToString(calcTemp / calcStorage); break; } } private void buttonPlus_Click(object sender, EventArgs e) { if (funtionKey != 0) functionProcess(); else { calcStorage = Convert.ToDouble(outPutBox.Text); outPutBox.Text = "0"; } funtionKey = 1; } private void button1_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "1"; else outPutBox.Text = outPutBox.Text + "1"; } private void button2_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "2"; else outPutBox.Text = outPutBox.Text + "2"; } private void button3_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "3"; else outPutBox.Text = outPutBox.Text + "3"; } private void button4_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "4"; else outPutBox.Text = outPutBox.Text + "4"; } private void button5_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "5"; else outPutBox.Text = outPutBox.Text + "5"; } private void button6_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "6"; else outPutBox.Text = outPutBox.Text + "6"; } private void button7_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "7"; else outPutBox.Text = outPutBox.Text + "7"; } private void button8_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "8"; else outPutBox.Text = outPutBox.Text + "8"; } private void button9_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "9"; else outPutBox.Text = outPutBox.Text + "9"; } private void buttonDecimal_Click(object sender, EventArgs e) { if (decmialOn != true) { if (outPutBox.Text == "0") outPutBox.Text = "0."; else outPutBox.Text = outPutBox.Text + "."; } else decmialOn = true; outPutBox.Text = outPutBox.Text; } private void buttonZero_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "0"; else outPutBox.Text = outPutBox.Text + "0"; } }}form1.designer.csnamespace Calc{ partial class Calc { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); this.button6 = new System.Windows.Forms.Button(); this.button7 = new System.Windows.Forms.Button(); this.button8 = new System.Windows.Forms.Button(); this.button9 = new System.Windows.Forms.Button(); this.buttonZero = new System.Windows.Forms.Button(); this.buttonDecimal = new System.Windows.Forms.Button(); this.outPutBox = new System.Windows.Forms.TextBox(); this.buttonMinus = new System.Windows.Forms.Button(); this.buttonDevide = new System.Windows.Forms.Button(); this.buttonMultiply = new System.Windows.Forms.Button(); this.buttonSign = new System.Windows.Forms.Button(); this.buttonPlus = new System.Windows.Forms.Button(); this.buttonBackSpace = new System.Windows.Forms.Button(); this.groupBoxNumbers = new System.Windows.Forms.GroupBox(); this.groupBoxFunctions = new System.Windows.Forms.GroupBox(); this.buttonEqules = new System.Windows.Forms.Button(); this.buttonClear = new System.Windows.Forms.Button(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.groupBoxMemory = new System.Windows.Forms.GroupBox(); this.buttonMemoryToggle = new System.Windows.Forms.Button(); this.button12 = new System.Windows.Forms.Button(); this.button11 = new System.Windows.Forms.Button(); this.button10 = new System.Windows.Forms.Button(); this.groupBoxNumbers.SuspendLayout(); this.groupBoxFunctions.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.groupBoxMemory.SuspendLayout(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(6, 94); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(42, 32); this.button1.TabIndex = 0; this.button1.Text = "1"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(54, 93); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(42, 32); this.button2.TabIndex = 1; this.button2.Text = "2"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // button3 // this.button3.Location = new System.Drawing.Point(102, 93); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(42, 32); this.button3.TabIndex = 2; this.button3.Text = "3"; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // // button4 // this.button4.Location = new System.Drawing.Point(6, 55); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(42, 32); this.button4.TabIndex = 3; this.button4.Text = "4"; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.button4_Click); // // button5 // this.button5.Location = new System.Drawing.Point(54, 55); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(42, 32); this.button5.TabIndex = 4; this.button5.Text = "5"; this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_Click); // // button6 // this.button6.Location = new System.Drawing.Point(102, 55); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(42, 32); this.button6.TabIndex = 5; this.button6.Text = "6"; this.button6.UseVisualStyleBackColor = true; this.button6.Click += new System.EventHandler(this.button6_Click); // // button7 // this.button7.Location = new System.Drawing.Point(6, 17); this.button7.Name = "button7"; this.button7.Size = new System.Drawing.Size(42, 32); this.button7.TabIndex = 8; this.button7.Text = "7"; this.button7.UseVisualStyleBackColor = true; this.button7.Click += new System.EventHandler(this.button7_Click); // // button8 // this.button8.Location = new System.Drawing.Point(54, 17); this.button8.Name = "button8"; this.button8.Size = new System.Drawing.Size(42, 32); this.button8.TabIndex = 7; this.button8.Text = "8"; this.button8.UseVisualStyleBackColor = true; this.button8.Click += new System.EventHandler(this.button8_Click); // // button9 // this.button9.Location = new System.Drawing.Point(102, 17); this.button9.Name = "button9"; this.button9.Size = new System.Drawing.Size(42, 32); this.button9.TabIndex = 6; this.button9.Text = "9"; this.button9.UseVisualStyleBackColor = true; this.button9.Click += new System.EventHandler(this.button9_Click); // // buttonZero // this.buttonZero.Location = new System.Drawing.Point(6, 129); this.buttonZero.Name = "buttonZero"; this.buttonZero.Size = new System.Drawing.Size(90, 32); this.buttonZero.TabIndex = 9; this.buttonZero.Text = "0"; this.buttonZero.UseVisualStyleBackColor = true; this.buttonZero.Click += new System.EventHandler(this.buttonZero_Click); // // buttonDecimal // this.buttonDecimal.Location = new System.Drawing.Point(102, 129); this.buttonDecimal.Name = "buttonDecimal"; this.buttonDecimal.Size = new System.Drawing.Size(42, 32); this.buttonDecimal.TabIndex = 10; this.buttonDecimal.Text = "."; this.buttonDecimal.UseVisualStyleBackColor = true; this.buttonDecimal.Click += new System.EventHandler(this.buttonDecimal_Click); // // outPutBox // this.outPutBox.Location = new System.Drawing.Point(76, 62); this.outPutBox.Name = "outPutBox"; this.outPutBox.Size = new System.Drawing.Size(160, 20); this.outPutBox.TabIndex = 11; // // buttonMinus // this.buttonMinus.Location = new System.Drawing.Point(5, 87); this.buttonMinus.Name = "buttonMinus"; this.buttonMinus.Size = new System.Drawing.Size(42, 32); this.buttonMinus.TabIndex = 12; this.buttonMinus.Text = "-"; this.buttonMinus.UseVisualStyleBackColor = true; // // buttonDevide // this.buttonDevide.Location = new System.Drawing.Point(5, 52); this.buttonDevide.Name = "buttonDevide"; this.buttonDevide.Size = new System.Drawing.Size(42, 32); this.buttonDevide.TabIndex = 13; this.buttonDevide.Text = "/"; this.buttonDevide.UseVisualStyleBackColor = true; // // buttonMultiply // this.buttonMultiply.Location = new System.Drawing.Point(4, 19); this.buttonMultiply.Name = "buttonMultiply"; this.buttonMultiply.Size = new System.Drawing.Size(42, 32); this.buttonMultiply.TabIndex = 14; this.buttonMultiply.Text = "*"; this.buttonMultiply.UseVisualStyleBackColor = true; // // buttonSign // this.buttonSign.Location = new System.Drawing.Point(5, 125); this.buttonSign.Name = "buttonSign"; this.buttonSign.Size = new System.Drawing.Size(42, 32); this.buttonSign.TabIndex = 15; this.buttonSign.Text = "+/-"; this.buttonSign.UseVisualStyleBackColor = true; // // buttonPlus // this.buttonPlus.Location = new System.Drawing.Point(48, 19); this.buttonPlus.Name = "buttonPlus"; this.buttonPlus.Size = new System.Drawing.Size(36, 101); this.buttonPlus.TabIndex = 16; this.buttonPlus.Text = "+"; this.buttonPlus.UseVisualStyleBackColor = true; this.buttonPlus.Click += new System.EventHandler(this.buttonPlus_Click); // // buttonBackSpace // this.buttonBackSpace.Location = new System.Drawing.Point(242, 55); this.buttonBackSpace.Name = "buttonBackSpace"; this.buttonBackSpace.Size = new System.Drawing.Size(42, 32); this.buttonBackSpace.TabIndex = 17; this.buttonBackSpace.Text = "<-"; this.buttonBackSpace.UseVisualStyleBackColor = true; // // groupBoxNumbers // this.groupBoxNumbers.Controls.Add(this.button1); this.groupBoxNumbers.Controls.Add(this.button2); this.groupBoxNumbers.Controls.Add(this.button3); this.groupBoxNumbers.Controls.Add(this.button4); this.groupBoxNumbers.Controls.Add(this.button5); this.groupBoxNumbers.Controls.Add(this.button6); this.groupBoxNumbers.Controls.Add(this.button7); this.groupBoxNumbers.Controls.Add(this.button8); this.groupBoxNumbers.Controls.Add(this.buttonDecimal); this.groupBoxNumbers.Controls.Add(this.button9); this.groupBoxNumbers.Controls.Add(this.buttonZero); this.groupBoxNumbers.Location = new System.Drawing.Point(76, 87); this.groupBoxNumbers.Name = "groupBoxNumbers"; this.groupBoxNumbers.Size = new System.Drawing.Size(160, 163); this.groupBoxNumbers.TabIndex = 18; this.groupBoxNumbers.TabStop = false; // // groupBoxFunctions // this.groupBoxFunctions.Controls.Add(this.buttonEqules); this.groupBoxFunctions.Controls.Add(this.buttonDevide); this.groupBoxFunctions.Controls.Add(this.buttonMultiply); this.groupBoxFunctions.Controls.Add(this.buttonSign); this.groupBoxFunctions.Controls.Add(this.buttonMinus); this.groupBoxFunctions.Controls.Add(this.buttonPlus); this.groupBoxFunctions.Location = new System.Drawing.Point(242, 93); this.groupBoxFunctions.Name = "groupBoxFunctions"; this.groupBoxFunctions.Size = new System.Drawing.Size(89, 186); this.groupBoxFunctions.TabIndex = 19; this.groupBoxFunctions.TabStop = false; this.groupBoxFunctions.Text = "Functions"; this.groupBoxFunctions.UseCompatibleTextRendering = true; // // buttonEqules // this.buttonEqules.Location = new System.Drawing.Point(47, 125); this.buttonEqules.Name = "buttonEqules"; this.buttonEqules.Size = new System.Drawing.Size(42, 32); this.buttonEqules.TabIndex = 17; this.buttonEqules.Text = "="; this.buttonEqules.UseVisualStyleBackColor = true; // // buttonClear // this.buttonClear.Location = new System.Drawing.Point(289, 55); this.buttonClear.Name = "buttonClear"; this.buttonClear.Size = new System.Drawing.Size(42, 32); this.buttonClear.TabIndex = 20; this.buttonClear.Text = "Clear"; this.buttonClear.UseVisualStyleBackColor = true; // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.editToolStripMenuItem, this.aboutToolStripMenuItem, this.settingsToolStripMenuItem, this.helpToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(338, 24); this.menuStrip1.TabIndex = 21; this.menuStrip1.Text = "menuStrip1"; // // editToolStripMenuItem // this.editToolStripMenuItem.Name = "editToolStripMenuItem"; this.editToolStripMenuItem.Size = new System.Drawing.Size(35, 20); this.editToolStripMenuItem.Text = "File"; // // aboutToolStripMenuItem // this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; this.aboutToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.aboutToolStripMenuItem.Text = "Edit"; // // settingsToolStripMenuItem // this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; this.settingsToolStripMenuItem.Size = new System.Drawing.Size(58, 20); this.settingsToolStripMenuItem.Text = "Settings"; // // helpToolStripMenuItem // this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; this.helpToolStripMenuItem.Size = new System.Drawing.Size(40, 20); this.helpToolStripMenuItem.Text = "Help"; // // groupBoxMemory // this.groupBoxMemory.Controls.Add(this.buttonMemoryToggle); this.groupBoxMemory.Controls.Add(this.button12); this.groupBoxMemory.Controls.Add(this.button11); this.groupBoxMemory.Controls.Add(this.button10); this.groupBoxMemory.Location = new System.Drawing.Point(12, 93); this.groupBoxMemory.Name = "groupBoxMemory"; this.groupBoxMemory.Size = new System.Drawing.Size(56, 171); this.groupBoxMemory.TabIndex = 22; this.groupBoxMemory.TabStop = false; this.groupBoxMemory.Text = "Mem"; this.groupBoxMemory.UseCompatibleTextRendering = true; // // buttonMemoryToggle // this.buttonMemoryToggle.FlatAppearance.BorderSize = 2; this.buttonMemoryToggle.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.buttonMemoryToggle.Location = new System.Drawing.Point(8, 19); this.buttonMemoryToggle.Name = "buttonMemoryToggle"; this.buttonMemoryToggle.Size = new System.Drawing.Size(42, 32); this.buttonMemoryToggle.TabIndex = 26; this.buttonMemoryToggle.UseVisualStyleBackColor = true; // // button12 // this.button12.Location = new System.Drawing.Point(8, 57); this.button12.Name = "button12"; this.button12.Size = new System.Drawing.Size(42, 32); this.button12.TabIndex = 25; this.button12.Text = "MC"; this.button12.UseVisualStyleBackColor = true; // // button11 // this.button11.Location = new System.Drawing.Point(8, 95); this.button11.Name = "button11"; this.button11.Size = new System.Drawing.Size(42, 32); this.button11.TabIndex = 24; this.button11.Text = "ML"; this.button11.UseVisualStyleBackColor = true; // // button10 // this.button10.Location = new System.Drawing.Point(8, 133); this.button10.Name = "button10"; this.button10.Size = new System.Drawing.Size(42, 32); this.button10.TabIndex = 23; this.button10.Text = "MR"; this.button10.UseVisualStyleBackColor = true; // // Calc // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(338, 291); this.Controls.Add(this.groupBoxMemory); this.Controls.Add(this.buttonClear); this.Controls.Add(this.groupBoxFunctions); this.Controls.Add(this.groupBoxNumbers); this.Controls.Add(this.buttonBackSpace); this.Controls.Add(this.outPutBox); this.Controls.Add(this.menuStrip1); this.MainMenuStrip = this.menuStrip1; this.Name = "Calc"; this.Text = "C# Calc"; this.groupBoxNumbers.ResumeLayout(false); this.groupBoxFunctions.ResumeLayout(false); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.groupBoxMemory.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button5; private System.Windows.Forms.Button button6; private System.Windows.Forms.Button button7; private System.Windows.Forms.Button button8; private System.Windows.Forms.Button button9; private System.Windows.Forms.Button buttonZero; private System.Windows.Forms.Button buttonDecimal; private System.Windows.Forms.TextBox outPutBox; private System.Windows.Forms.Button buttonMinus; private System.Windows.Forms.Button buttonDevide; private System.Windows.Forms.Button buttonMultiply; private System.Windows.Forms.Button buttonSign; private System.Windows.Forms.Button buttonPlus; private System.Windows.Forms.Button buttonBackSpace; private System.Windows.Forms.GroupBox groupBoxNumbers; private System.Windows.Forms.GroupBox groupBoxFunctions; private System.Windows.Forms.Button buttonClear; private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; private System.Windows.Forms.GroupBox groupBoxMemory; private System.Windows.Forms.ToolStripMenu Edited March 7, 2006 by iccaros Quote Link to post Share on other sites
iccaros Posted March 15, 2006 Author Report Share Posted March 15, 2006 ok got it working.. maybe some one has ideal on doing this betterusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Calc{ public partial class Calc : Form { public Calc() { InitializeComponent(); } private int funtionKey = 0;// int funtion key to allow case of function choosen private bool decmialOn = false;//to disally multiple decmial points on a line private double calcStorage = 0.0; private int funtionDisplayCheck = 0; private double memorySpace = 0.0; private void functionProcess() { //this funtion will do all processing of /*-+ //this will be a case statment that will check the value //of funtionKey 1 for addition 2 for subtract, 4 for devide, 3 for multiply double calcTemp = calcStorage; calcStorage = Convert.ToDouble(outPutBox.Text); switch (funtionKey) { case 1: outPutBox.Text = Convert.ToString(calcTemp + calcStorage); break; case 2: outPutBox.Text = Convert.ToString(calcTemp - calcStorage); break; case 3: outPutBox.Text = Convert.ToString(calcTemp * calcStorage); break; case 4: outPutBox.Text = Convert.ToString(calcTemp / calcStorage); break; } } private void button1_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") { outPutBox.Text = "1"; } else if (funtionDisplayCheck != 0) { outPutBox.Text = "1"; funtionDisplayCheck = 0; } else outPutBox.Text = outPutBox.Text + "1"; } private void button2_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "2"; else if (funtionDisplayCheck != 0) { outPutBox.Text = "2"; funtionDisplayCheck = 0; } else outPutBox.Text = outPutBox.Text + "2"; } private void button3_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "3"; else if (funtionDisplayCheck != 0) { outPutBox.Text = "3"; funtionDisplayCheck = 0; } else outPutBox.Text = outPutBox.Text + "3"; } private void button4_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "4"; else if (funtionDisplayCheck != 0) { outPutBox.Text = "4"; funtionDisplayCheck = 0; } else outPutBox.Text = outPutBox.Text + "4"; } private void button5_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "5"; else if (funtionDisplayCheck != 0) { outPutBox.Text = "5"; funtionDisplayCheck = 0; } else outPutBox.Text = outPutBox.Text + "5"; } private void button6_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "6"; else if (funtionDisplayCheck != 0) { outPutBox.Text = "6"; funtionDisplayCheck = 0; } else outPutBox.Text = outPutBox.Text + "6"; } private void button7_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "7"; else if (funtionDisplayCheck != 0) { outPutBox.Text = "7"; funtionDisplayCheck = 0; } else outPutBox.Text = outPutBox.Text + "7"; } private void button8_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "8"; else if (funtionDisplayCheck != 0) { outPutBox.Text = "8"; funtionDisplayCheck = 0; } else outPutBox.Text = outPutBox.Text + "8"; } private void button9_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "9"; else if (funtionDisplayCheck != 0) { outPutBox.Text = "9"; funtionDisplayCheck = 0; } else outPutBox.Text = outPutBox.Text + "9"; } private void buttonDecimal_Click(object sender, EventArgs e) { if (decmialOn) return; else if (outPutBox.Text == "0") outPutBox.Text = "0."; else outPutBox.Text = outPutBox.Text + "."; decmialOn = true; } private void buttonZero_Click(object sender, EventArgs e) { if (outPutBox.Text == "0") outPutBox.Text = "0"; else if (funtionDisplayCheck != 0) { outPutBox.Text = "0"; funtionDisplayCheck = 0; } else outPutBox.Text = outPutBox.Text + "0"; } private void buttonEqules_Click(object sender, EventArgs e) { //do math functionProcess(); //reset keys funtionKey = 0; decmialOn = false; buttonMemoryToggle.Text = ""; } private void buttonPlus_Click(object sender, EventArgs e) { if (funtionKey != 0) functionProcess(); else { calcStorage = Convert.ToDouble(outPutBox.Text); // outPutBox.Text = "0"; } funtionKey = 1; funtionDisplayCheck = 1; } private void buttonMultiply_Click(object sender, EventArgs e) { if (funtionKey != 0) functionProcess(); else { calcStorage = Convert.ToDouble(outPutBox.Text); //outPutBox.Text = "0"; } funtionKey = 3; funtionDisplayCheck = 1; } private void buttonMinus_Click(object sender, EventArgs e) { if (funtionKey != 0) functionProcess(); else { calcStorage = Convert.ToDouble(outPutBox.Text); //outPutBox.Text = "0"; } funtionKey = 2; funtionDisplayCheck = 1; } private void buttonDevide_Click(object sender, EventArgs e) { if (funtionKey != 0) functionProcess(); else { calcStorage = Convert.ToDouble(outPutBox.Text); //outPutBox.Text = "0"; } funtionKey = 4; funtionDisplayCheck = 1; } private void buttonBackSpace_Click(object sender, EventArgs e) { string outPutTemp = outPutBox.Text; if (outPutTemp.Length > 1) outPutTemp = outPutTemp.Substring(0, outPutTemp.Length - 1); else outPutTemp = "0"; outPutBox.Text = outPutTemp; } private void buttonClear_Click(object sender, EventArgs e) { outPutBox.Text = "0"; decmialOn = false; } private void buttonSign_Click(object sender, EventArgs e) { double tempHolder = 0; tempHolder = Convert.ToDouble(outPutBox.Text); tempHolder = -(tempHolder); outPutBox.Text = Convert.ToString(tempHolder); } private void buttonSQR_Click(object sender, EventArgs e) { calcStorage = Convert.ToDouble(outPutBox.Text); calcStorage = Math.Sqrt(calcStorage); outPutBox.Text = Convert.ToString(calcStorage); } private void buttonMemoryClear_Click(object sender, EventArgs e) { memorySpace = 0.0; buttonMemoryToggle.Text = ""; } private void buttonStorage_Click(object sender, EventArgs e) { memorySpace = Convert.ToDouble(outPutBox.Text); buttonMemoryToggle.Text = "M"; } private void buttonMemoryRelease_Click(object sender, EventArgs e) { outPutBox.Text = Convert.ToString(memorySpace); } private void buttonMemory_Click(object sender, EventArgs e) { double tempMem = 0; tempMem = Convert.ToDouble(outPutBox.Text ); memorySpace = memorySpace + tempMem; outPutBox.Text = Convert.ToString(memorySpace); } }} Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.