// Przyciski:
private: System::Void zero_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="0";
this->textBox2->Text+="0";
this->textBox4->Text="0";
}
private: System::Void jeden_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="1";
this->textBox2->Text+="1";
this->textBox4->Text="0";
}
private: System::Void dwa_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="2";
this->textBox2->Text+="2";
this->textBox4->Text="0";
}
private: System::Void trzy_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="3";
this->textBox2->Text+="3";
this->textBox4->Text="0";
}
private: System::Void cztery_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="4";
this->textBox2->Text+="4";
this->textBox4->Text="0";
}
private: System::Void piec_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="5";
this->textBox2->Text+="5";
this->textBox4->Text="0";
}
private: System::Void szesc_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="6";
this->textBox2->Text+="6";
this->textBox4->Text="0";
}
private: System::Void siedem_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="7";
this->textBox2->Text+="7";
this->textBox4->Text="0";
}
private: System::Void osiem_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="8";
this->textBox2->Text+="8";
this->textBox4->Text="0";
}
private: System::Void dziewiec_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="9";
this->textBox2->Text+="9";
this->textBox4->Text="0";
}
private: System::Void clear_Click(System::Object^ sender, System::EventArgs^ e) {
textBox1->Clear();
textBox2->Clear();
textBox3->Clear();
this->textBox5->Text="0";
this-> textBox4->Text="0";
label1->Text="Kalkulator";
}
private: System::Void zamknijToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
private: System::Void przecinek_Click(System::Object^ sender, System::EventArgs^ e) {
int a = 0;
int lent = textBox1->Text->Length;
for(int i = 0; i< lent; i=i+1){
textBox4->Text = textBox1->Text;
if(textBox4->Text[i].ToString() == ","){
a = 1;}
}
if (a==1){ MessageBox::Show("Nie mozna wstawic przecinka!");}
else { if(textBox1->Text==""){
this->textBox1->Text+="0,";
this->textBox2->Text+="0,";
}else {
this->textBox1->Text+=",";
this->textBox2->Text+=",";
}}
}
private: System::Void dodac_Click(System::Object^ sender, System::EventArgs^ e) {
if(textBox2->Text!=""){
if(label1->Text=="/"){
double a=1;
if(textBox1->Text!=""){
a=Convert::ToDouble(textBox1->Text);
if(a==0)
{MessageBox::Show("Nie dzielimy przez 0!");}
else{
textBox1->Clear();
textBox2->Text+="+";
label1->Text="+";
textBox4->Text="1";
} }else {textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
textBox2->Text+="+";
label1->Text="+";}
}
else {
if(textBox4->Text=="1"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
textBox2->Text+="+";
label1->Text="+";}
else{
this->textBox4->Text="0";
textBox1->Clear();
textBox2->Text+="+";
label1->Text="+";
textBox4->Text="1";
}}}}
private: System::Void odejmowanie_Click(System::Object^ sender, System::EventArgs^ e) {
if(textBox2->Text!=""){
if(label1->Text=="/"){
double a=1;
if(textBox1->Text!=""){
a=Convert::ToDouble(textBox1->Text);
if(a==0)
{MessageBox::Show("Nie dzielimy przez 0!");}
else{
textBox1->Clear();
textBox2->Text+="-";
label1->Text="-";
textBox4->Text="1";
} }else {textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
textBox2->Text+="-";
label1->Text="-";}
}
else {
if(textBox4->Text=="1"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
textBox2->Text+="-";
label1->Text="-";}
else{
this->textBox4->Text="0";
textBox1->Clear();
textBox2->Text+="-";
label1->Text="-";
textBox4->Text="1";
}}}}
private: System::Void mnozenie_Click(System::Object^ sender, System::EventArgs^ e) {
if(textBox2->Text!=""){
if(label1->Text=="/"){
double a=1;
if(textBox1->Text!=""){
a=Convert::ToDouble(textBox1->Text);
if(a==0)
{MessageBox::Show("Nie dzielimy przez 0!");}
else{
textBox1->Clear();
textBox2->Text+="*";
label1->Text="*";
textBox4->Text="1";
} }else {textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
textBox2->Text+="*";
label1->Text="*";}
}
else {
if(textBox4->Text=="1"){
textBox2->Text=textBox2->Text->Substring(0, textBox2->Text->Length -1);
textBox2->Text+="*";
label1->Text="*";}
else{
this->textBox4->Text="0";
textBox1->Clear();
textBox2->Text+="*";
label1->Text="*";
textBox4->Text="1";
}}}}
private: System::Void dzielenie_Click(System::Object^ sender, System::EventArgs^ e) {
if(textBox2->Text!=""){
if(label1->Text=="/"){
double a;
if(textBox1->Text!=""){
a=Convert::ToDouble(textBox1->Text);
if(a==0)
{MessageBox::Show("Nie dzielimy przez 0!");}
else{
textBox1->Clear();
textBox2->Text+="/";
label1->Text="/";
textBox4->Text="1";
} } else {textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
textBox2->Text+="/";
label1->Text="/";}
}
else {
if(textBox4->Text=="1"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
textBox2->Text+="/";
label1->Text="/";}
else{
this->textBox4->Text="0";
textBox1->Clear();
textBox2->Text+="/";
label1->Text="/";
textBox4->Text="1";
}}}}
private: System::Void pierwiastek_Click(System::Object^ sender, System::EventArgs^ e) {
if(label1->Text=="Kalkulator"){ this->textBox4->Text="0";
if(textBox1->Text==""){ MessageBox::Show("Nie wpisano żadnej liczby");
} else {
double a,b;
int lent=textBox1->Text->Length;
a = Convert::ToDouble (textBox1->Text);
b = Math::Sqrt(a);
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -lent);
textBox1->Text=Convert::ToString(b);
textBox2->Text+=Convert::ToString(b);
this->textBox5->Text="1";
label1->Text="sqrt";
}} else {
this->textBox4->Text="0";
if(textBox1->Text==""){ MessageBox::Show("Nie wpisano żadnej liczby");
} else {
double a,b;
int lent=textBox1->Text->Length;
a = Convert::ToDouble (textBox1->Text);
b = Math::Sqrt(a);
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -lent);
textBox1->Text=Convert::ToString(b);
textBox2->Text+=Convert::ToString(b);
this->textBox5->Text="1";
} }
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
int lent = textBox1->Text->Length;
int a = lent -1;
if(lent>=1){
textBox1->Text = textBox1->Text->Substring(0, textBox1->Text->Length -1);
textBox2->Text = textBox2->Text->Substring(0, textBox2->Text->Length -1);
}
}
private: System::Void potega_Click(System::Object^ sender, System::EventArgs^ e) {
if(label1->Text=="Kalkulator"){ this->textBox4->Text="0";
if(textBox1->Text==""){ MessageBox::Show("Nie wpisano żadnej liczby");
} else {
double a,b;
int lent=textBox1->Text->Length;
a=Convert::ToDouble(textBox1->Text);
b=a*a;
// for(int i=1; i<=lent; i++)
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -lent);
textBox1->Text=Convert::ToString(b);
textBox2->Text+=Convert::ToString(b);
this->textBox5->Text="1";
label1->Text="^2";
}} else {
this->textBox4->Text="0";
if(textBox1->Text==""){ MessageBox::Show("Nie wpisano żadnej liczby");
} else {
double a,b;
int lent=textBox1->Text->Length;
a=Convert::ToDouble(textBox1->Text);
b=a*a;
// for(int i=1; i<=lent; i++)
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -lent);
textBox1->Text=Convert::ToString(b);
textBox2->Text+=Convert::ToString(b);
this->textBox5->Text="1";
label1->Text="^2";
}
}
}
private: System::Void pi_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="3,14159";
this->textBox2->Text+="3,14159";
this->textBox4->Text="0";
}
private: System::Void Euler_Click(System::Object^ sender, System::EventArgs^ e) {
this->textBox1->Text+="2,71828";
this->textBox2->Text+="2,71828";
this->textBox4->Text="0";
}
private: System::Void sinus_Click(System::Object^ sender, System::EventArgs^ e) {
if(textBox1->Text==""){
MessageBox::Show("Nie wpisano zadnej liczby");
}
else { double q;
q = Convert::ToDouble (textBox1->Text);
while (q>360){
q = q - 360;
}
textBox1->Text=Convert::ToString(q);
if(textBox1->Text=="180"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -3);
double a;
a = Convert::ToDouble (textBox1->Text);
x = 0;
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";}
else {if(textBox1->Text=="360"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -3);
double a;
a = Convert::ToDouble (textBox1->Text);
x = 0;
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";}
else {
if(textBox1->Text->Length==1){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
double a;
a = Convert::ToDouble (textBox1->Text);
x = Math::Sin(a*3.14159265358979/180);
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";}
else{
if(textBox1->Text->Length==2){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -2);
double a;
a = Convert::ToDouble (textBox1->Text);
x = Math::Sin(a*3.14159265358979/180);
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
}
else{
if(textBox1->Text->Length==3){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -3);
double a;
a = Convert::ToDouble (textBox1->Text);
x = Math::Sin(a*3.14159265358979/180);
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
}
}
}}}
}}
private: System::Void cosinus_Click(System::Object^ sender, System::EventArgs^ e) {
if(textBox1->Text==""){
MessageBox::Show("Nie wpisano zadnej liczby");
}
else { double q;
q = Convert::ToDouble (textBox1->Text);
while (q>360){
q = q - 360;
}
textBox1->Text=Convert::ToString(q);
if(textBox1->Text=="90"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -2);
double a;
a = Convert::ToDouble (textBox1->Text);
x = 0;
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";}
else{if(textBox1->Text=="60"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -2);
double a;
a = Convert::ToDouble (textBox1->Text);
x = 0.5;
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";
}
else {if(textBox1->Text=="270"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -3);
double a;
a = Convert::ToDouble (textBox1->Text);
x = 0;
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";}
else {
if(textBox1->Text->Length==1){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
double a;
a = Convert::ToDouble (textBox1->Text);
x = Math::Sin(a*3.14159265358979/180);
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";}
else{
if(textBox1->Text->Length==2){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -2);
double a;
a = Convert::ToDouble (textBox1->Text);
x = Math::Cos(a*3.14159265358979/180);
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
}
else{
if(textBox1->Text->Length==3){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -3);
double a;
a = Convert::ToDouble (textBox1->Text);
x = Math::Sin(a*3.14159265358979/180);
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
}
}
}}}
}}}
private: System::Void tangens_Click(System::Object^ sender, System::EventArgs^ e) {
if(textBox1->Text==""){
MessageBox::Show("Nie wpisano zadnej liczby");
}
else { double q;
q = Convert::ToDouble (textBox1->Text);
while (q>360){
q = q - 360;
}
textBox1->Text=Convert::ToString(q);
if(textBox1->Text=="180"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -3);
double a;
a = Convert::ToDouble (textBox1->Text);
x = 0;
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";}
else {if(textBox1->Text=="360"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -3);
double a;
a = Convert::ToDouble (textBox1->Text);
x = 0;
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";}
else{if(textBox1->Text=="90"){
MessageBox::Show("Nie ma tg z 90");
this->textBox5->Text="1";
}else{if(textBox1->Text=="270"){
MessageBox::Show("Nie ma tg z 90");
this->textBox5->Text="1";
}else{if(textBox1->Text=="45"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -2);
double a;
a = Convert::ToDouble (textBox1->Text);
x = 1;
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";}
else{
if(textBox1->Text->Length==1){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
double a;
a = Convert::ToDouble (textBox1->Text);
x = Math::Sin(a*3.14159265358979/180);
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
this->textBox5->Text="1";}
else{
if(textBox1->Text->Length==2){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -2);
double a;
a = Convert::ToDouble (textBox1->Text);
x = Math::Cos(a*3.14159265358979/180);
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
}
else{
if(textBox1->Text->Length==3){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -3);
double a;
a = Convert::ToDouble (textBox1->Text);
x = Math::Tan(a*3.14159265358979/180);
textBox1->Text=Convert::ToString(x);
textBox2->Text+=Convert::ToString(x);
}
}
}}}
}}}}}
private: System::Void rownosc_Click(System::Object^ sender, System::EventArgs^ e) {
if(textBox2->Text!=""){
if(label1->Text=="/"){
double a=1;
if(textBox1->Text!=""){
a=Convert::ToDouble(textBox1->Text);
if(a==0)
{MessageBox::Show("Nie dzielimy przez 0!");}
else{
textBox1->Clear();
textBox2->Text+="=";
label1->Text="=";
textBox4->Text="1";
} }else {textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
textBox2->Text+="=";
label1->Text="=";}
}
else {
if(textBox4->Text=="1"){
textBox2->Text =textBox2->Text->Substring(0, textBox2->Text->Length -1);
textBox2->Text+="=";
label1->Text="=";}
else{
this->textBox4->Text="0";
textBox1->Clear();
textBox2->Text+="=";
label1->Text="=";
textBox4->Text="1";
}}}
if(label1->Text=="="){
textBox3->Text=textBox2->Text->Substring(0, textBox2->Text->Length -1);
int lent1 = textBox3->Text->Length;
// char b;
// for(int i = 0; i< lent1; i=i+1){
// c[i] = textBox3->Text[i].ToString();
// }
textBox3->Text=Convert::ToString(Wynik.RPN(textBox3->Text)); //Napisz String ( z dużej litery, żeby działało, to system string będzie)
// Convert::ToString
} }