public static bool commacheck(string Formula, double ekaluku, bool ekacheck, char[] ops) { if (Myclass.tarkistin(Formula)) { return(true); } string v = Formula[Formula.Length - 1].ToString(); int ekalength = ekaluku.ToString().Length; int kokolength = Formula.Length; int tokalength = kokolength - ekalength; char[] ekamerkit = Formula.Substring(0, kokolength).ToArray(); char[] tokamerkit = Formula.Substring(ekalength, tokalength).ToArray(); if (ekamerkit.Contains(',') && !ekacheck) { return(true); } foreach (char c in ops) { if (ekamerkit.Contains(c) && tokamerkit.Contains(',')) { return(true); } } return(false); }
private void Equal_Click_1(object sender, EventArgs e) { debug(); if (Myclass.tarkistin(Formula.Text) || tuloscheck) { } else if (!tokacheck && ekacheck) { if (!tuloscheck) { tokaluku = Double.Parse(Formula.Text.Substring(ekaluku.ToString().Length + 1)); } ; if (op == '-') { tulos = ekaluku - tokaluku; } else if (op == '/') { tulos = ekaluku / tokaluku; } else if (op == '+') { tulos = ekaluku + tokaluku; } else if (op == '*') { tulos = ekaluku * tokaluku; } Result.Text = tulos.ToString("0.########"); ekaluku = tulos; tokaluku = 0; tuloscheck = true; } }
private void Comma_Click(object sender, EventArgs e) { if (Myclass.tarkistin(Formula.Text) || tuloscheck) { } else if (Myclass.commacheck(Formula.Text, ekaluku, ekacheck, ops)) { } else { result += ","; Formula.Text += ","; } }
private void Divide_Click(object sender, EventArgs e) { Button b = (Button)sender; if (Myclass.tarkistin(Formula.Text)) { } else if (tuloscheck) { Formula.Text = tulos.ToString(); Formula.Text += b.Text; op = Char.Parse(b.Text); tuloscheck = false; } else if (!ekacheck) { ekaluku = Double.Parse(Formula.Text); ekacheck = true; Formula.Text += b.Text; op = Char.Parse(b.Text); } debug(); }
private void Zero_Click(object sender, EventArgs e) { Myclass.nappi(Formula, result, tuloscheck, sender); }