Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/04/2011, 17:01
Avatar de saudakar
saudakar
 
Fecha de Ingreso: octubre-2010
Ubicación: Donde pueda beber Cafe
Mensajes: 11
Antigüedad: 13 años, 7 meses
Puntos: 5
Respuesta: Calculadora - WindowsForms - c++

Resolvi el problema :)

Gracias por su atencion,... Dejo el codigo de como lo solucione por si alguien le pasa igual,...

Código C++:
Ver original
  1. /*Todos los botones llevan el mismo codigo, solo cambia el numero que agregan*/
  2. private: System::Void button9_Click(System::Object^  sender, System::EventArgs^  e)
  3.          {
  4.           this->T1->Text = this->T1->Text + "9";
  5.          }
  6. private: System::Void Bresta_Click(System::Object^  sender, System::EventArgs^  e)
  7.          {
  8.             numero1 = Convert::ToDouble(this->T1->Text);
  9.             this->T1->Text="";
  10.             operacion ='-';
  11.          }
  12. private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
  13.          }
  14. private: System::Void b0_Click(System::Object^  sender, System::EventArgs^  e)
  15.          {
  16.           this->T1->Text = this->T1->Text + "0";
  17.          }
  18. private: System::Void Bsuma_Click(System::Object^  sender, System::EventArgs^  e)
  19.          {/*Aca se coloca el valor de la caja de texto a una variable,...
  20.                       Como describi en mi algoritmo*/
  21.             numero1 = Convert::ToDouble(this->T1->Text);
  22.             this->T1->Text="";
  23.             operacion ='+';
  24.         /*Para todas las operaciones es el mismo codigo, solamente se cambia el  signo*/
  25.                   }
  26. private: System::Void Bmulti_Click(System::Object^  sender, System::EventArgs^  e)
  27.          {
  28.             numero1 = Convert::ToDouble(this->T1->Text);
  29.             this->T1->Text="";
  30.             operacion ='*';
  31.          }
  32. private: System::Void Bdiv_Click(System::Object^  sender, System::EventArgs^  e)
  33.          {
  34.             numero1 = Convert::ToDouble(this->T1->Text);
  35.             this->T1->Text="";
  36.             operacion ='/';
  37.          }
  38. private: System::Void Bresultado_Click(System::Object^  sender, System::EventArgs^  e)
  39.          {/*Se asigna el Valor de la caja de texto a otra variable
  40.                   y se determina que operacion realizar en base al signo
  41.                   que contenga la variable "char operacion"*/
  42.            numero2 = Convert::ToDouble(this->T1->Text);
  43.            switch(operacion)
  44.            {
  45.             case '-': total = (numero1 - numero2);break;
  46.             case '+': total = (numero1 + numero2);break;
  47.             case '*': total = (numero1 * numero2);break;
  48.             case '/': total = (numero1 / numero2);break;
  49.            }
  50.           this->T1->Text=Convert::ToString(total);
  51.          }
  52. private: System::Void Bpunto_Click(System::Object^  sender, System::EventArgs^  e)
  53.          {
  54.           this->T1->Text = this->T1->Text + ".";
  55.          }
  56. private: System::Void BLimpiar_Click(System::Object^  sender, System::EventArgs^  e)
  57.          {
  58.           this->T1->Text="";
  59.          }
  60. private: System::Void Bclr_Click(System::Object^  sender, System::EventArgs^  e)
  61.          {
  62.           this->T1->Text="";
  63.           numero1 = 0;
  64.           numero2 = 0;
  65.           total   = 0;
  66.          }
  67. };