private void numerosIngresados_TextChanged(object sender, EventArgs e) { clConverter objConverter = new clConverter(numerosIngresados.Text); try { if (rbBin.Checked == true) { resulBinario.Text = numerosIngresados.Text; resulOctal.Text = objConverter.BinaryToOctal(); resulDecimal.Text = objConverter.BinaryToDecimal(); resulHexa.Text = objConverter.BinaryToHexadecimal().ToUpper(); } if (rbOctal.Checked == true) { resulBinario.Text = objConverter.OctalToBinary(); resulOctal.Text = numerosIngresados.Text; resulDecimal.Text = objConverter.OctalToDecimal(); resulHexa.Text = objConverter.OctalToHexadecimal().ToUpper(); } if (rbDeci.Checked == true) { resulBinario.Text = objConverter.DecimalToBinary(); resulOctal.Text = objConverter.DecimalToOctal(); resulDecimal.Text = numerosIngresados.Text; resulHexa.Text = objConverter.DecimalToHexadecimal().ToUpper(); } if (rbHex.Checked == true) { resulBinario.Text = objConverter.HexadecimalToBinary(); resulOctal.Text = objConverter.HexadecimalToOctal(); resulDecimal.Text = objConverter.HexadecimalToDecimal(); resulHexa.Text = numerosIngresados.Text; } if (numerosIngresados.Text == "") { numerosIngresados.Text = "0"; } } catch { } }
private void operaciones(string simbolo) { if (simbolo == "+" || simbolo == "-" || simbolo == "=") { operacion = memoria.Text.Remove(memoria.Text.Length - (i + 1)); try { switch (operacion.Substring(operacion.Length - 1)) { case "+": total += valor1; total = Math.Round(total); break; case "-": total -= valor1; total = Math.Round(total); break; case "*": operacion = memoria.Text.Remove(memoria.Text.Length - j); if (operacion.Substring(operacion.Length - 1) == "+") { total += aux; total = Math.Round(total); } else if (operacion.Substring(operacion.Length - 1) == "-") { total -= aux; total = Math.Round(total); } break; case "/": operacion = memoria.Text.Remove(memoria.Text.Length - j); if (operacion.Substring(operacion.Length - 1) == "+") { total += aux; total = Math.Round(total); } else if (operacion.Substring(operacion.Length - 1) == "-") { total -= aux; total = Math.Round(total); } break; } } catch { total += valor1; total = Math.Round(total); } } else { } clConverter objConverter = new clConverter(Math.Round(total).ToString()); if (rbBin.Checked == true) { numerosIngresados.Text = objConverter.DecimalToBinary(); } if (rbOctal.Checked == true) { numerosIngresados.Text = objConverter.DecimalToOctal(); } if (rbDeci.Checked == true) { numerosIngresados.Text = total.ToString(); } if (rbHex.Checked == true) { numerosIngresados.Text = objConverter.DecimalToHexadecimal(); numerosIngresados.Text = numerosIngresados.Text.ToUpper(); } }