problem podwójnego przecinka i błędu przy wykonywaniu działań

0

namespace zaliczenie {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
///          'Resource File Name' property for the managed resource compiler tool
///          associated with all .resx files this class depends on.  Otherwise,
///          the designers will not be able to interact properly with localized
///          resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
	Form1(void)
	{
		InitializeComponent();
		//
		//TODO: Add the constructor code here
		//
	}

protected:
	/// <summary>
	/// Clean up any resources being used.
	/// </summary>
	~Form1()
	{
		if (components)
		{
			delete components;
		}
	}
private: System::Windows::Forms::TextBox^  textBox1;
protected: 
private: System::Windows::Forms::TextBox^  textBox2;
private: System::Windows::Forms::RadioButton^  radioButton1;
private: System::Windows::Forms::RadioButton^  radioButton2;
private: System::Windows::Forms::Label^  label1;
private: System::Windows::Forms::Label^  label2;
private: System::Windows::Forms::TextBox^  textBox3;
private: System::Windows::Forms::Label^  label3;
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^  button10;
private: System::Windows::Forms::Button^  button11;
private: System::Windows::Forms::Button^  button12;
private: System::Windows::Forms::Button^  button13;
private: System::Windows::Forms::Button^  button14;
private: System::Windows::Forms::Button^  button16;
private: System::Windows::Forms::Button^  button15;
private: System::Windows::Forms::Button^  button17;

private:
	/// <summary>
	/// Required designer variable.
	/// </summary>
	System::ComponentModel::Container ^components;

#pragma 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>
void InitializeComponent(void)
{
this->textBox1 = (gcnew System::TextBox());
this->textBox2 = (gcnew System::TextBox());
this->radioButton1 = (gcnew System::RadioButton());
this->radioButton2 = (gcnew System::RadioButton());
this->label1 = (gcnew System::Label());
this->label2 = (gcnew System::Label());
this->textBox3 = (gcnew System::TextBox());
this->label3 = (gcnew System::Label());
this->button1 = (gcnew System::Button());
this->button2 = (gcnew System::Button());
this->button3 = (gcnew System::Button());
this->button4 = (gcnew System::Button());
this->button5 = (gcnew System::Button());
this->button6 = (gcnew System::Button());
this->button7 = (gcnew System::Button());
this->button8 = (gcnew System::Button());
this->button9 = (gcnew System::Button());
this->button10 = (gcnew System::Button());
this->button11 = (gcnew System::Button());
this->button12 = (gcnew System::Button());
this->button13 = (gcnew System::Button());
this->button14 = (gcnew System::Button());
this->button16 = (gcnew System::Button());
this->button15 = (gcnew System::Button());
this->button17 = (gcnew System::Button());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Location = System::Point(103, 12);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Size(121, 20);
this->textBox1->TabIndex = 0;
//
// textBox2
//
this->textBox2->Location = System::Point(103, 44);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Size(121, 20);
this->textBox2->TabIndex = 1;
//
// radioButton1
//
this->radioButton1->AutoSize = true;
this->radioButton1->Checked = true;
this->radioButton1->Location = System::Point(83, 15);
this->radioButton1->Name = L"radioButton1";
this->radioButton1->Size = System::Size(14, 13);
this->radioButton1->TabIndex = 2;
this->radioButton1->TabStop = true;
this->radioButton1->UseVisualStyleBackColor = true;
//
// radioButton2
//
this->radioButton2->AutoSize = true;
this->radioButton2->Location = System::Point(83, 46);
this->radioButton2->Name = L"radioButton2";
this->radioButton2->Size = System::Size(14, 13);
this->radioButton2->TabIndex = 3;
this->radioButton2->TabStop = true;
this->radioButton2->UseVisualStyleBackColor = true;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Point(18, 15);
this->label1->Name = L"label1";
this->label1->Size = System::Size(48, 13);
this->label1->TabIndex = 4;
this->label1->Text = L"Liczba X";
this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Point(18, 47);
this->label2->Name = L"label2";
this->label2->Size = System::Size(48, 13);
this->label2->TabIndex = 5;
this->label2->Text = L"Liczba Y";
//
// textBox3
//
this->textBox3->Location = System::Point(103, 74);
this->textBox3->Name = L"textBox3";
this->textBox3->ReadOnly = true;
this->textBox3->Size = System::Size(120, 20);
this->textBox3->TabIndex = 6;
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Point(18, 77);
this->label3->Name = L"label3";
this->label3->Size = System::Size(81, 13);
this->label3->TabIndex = 7;
this->label3->Text = L"Wynik dzialania";
//
// button1
//
this->button1->Location = System::Point(21, 112);
this->button1->Name = L"button1";
this->button1->Size = System::Size(34, 28);
this->button1->TabIndex = 8;
this->button1->Text = L"1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// button2
//
this->button2->Location = System::Point(61, 112);
this->button2->Name = L"button2";
this->button2->Size = System::Size(34, 28);
this->button2->TabIndex = 9;
this->button2->Text = L"2";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// button3
//
this->button3->Location = System::Point(101, 112);
this->button3->Name = L"button3";
this->button3->Size = System::Size(34, 28);
this->button3->TabIndex = 10;
this->button3->Text = L"3";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
//
// button4
//
this->button4->Location = System::Point(21, 146);
this->button4->Name = L"button4";
this->button4->Size = System::Size(34, 28);
this->button4->TabIndex = 11;
this->button4->Text = L"4";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
//
// button5
//
this->button5->Location = System::Point(61, 146);
this->button5->Name = L"button5";
this->button5->Size = System::Size(34, 28);
this->button5->TabIndex = 12;
this->button5->Text = L"5";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
//
// button6
//
this->button6->Location = System::Point(101, 146);
this->button6->Name = L"button6";
this->button6->Size = System::Size(34, 28);
this->button6->TabIndex = 13;
this->button6->Text = L"6";
this->button6->UseVisualStyleBackColor = true;
this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click);
//
// button7
//
this->button7->Location = System::Point(21, 180);
this->button7->Name = L"button7";
this->button7->Size = System::Size(34, 28);
this->button7->TabIndex = 14;
this->button7->Text = L"7";
this->button7->UseVisualStyleBackColor = true;
this->button7->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
//
// button8
//
this->button8->Location = System::Point(61, 180);
this->button8->Name = L"button8";
this->button8->Size = System::Size(34, 28);
this->button8->TabIndex = 15;
this->button8->Text = L"8";
this->button8->UseVisualStyleBackColor = true;
this->button8->Click += gcnew System::EventHandler(this, &Form1::button8_Click);
//
// button9
//
this->button9->Location = System::Point(101, 180);
this->button9->Name = L"button9";
this->button9->Size = System::Size(34, 28);
this->button9->TabIndex = 16;
this->button9->Text = L"9";
this->button9->UseVisualStyleBackColor = true;
this->button9->Click += gcnew System::EventHandler(this, &Form1::button9_Click);
//
// button10
//
this->button10->Location = System::Point(21, 214);
this->button10->Name = L"button10";
this->button10->Size = System::Size(34, 28);
this->button10->TabIndex = 17;
this->button10->Text = L",";
this->button10->UseVisualStyleBackColor = true;
this->button10->Click += gcnew System::EventHandler(this, &Form1::button10_Click);
//
// button11
//
this->button11->Location = System::Point(61, 214);
this->button11->Name = L"button11";
this->button11->Size = System::Size(74, 28);
this->button11->TabIndex = 18;
this->button11->Text = L"0";
this->button11->UseVisualStyleBackColor = true;
this->button11->Click += gcnew System::EventHandler(this, &Form1::button11_Click);
//
// button12
//
this->button12->Location = System::Point(150, 112);
this->button12->Name = L"button12";
this->button12->Size = System::Size(34, 28);
this->button12->TabIndex = 19;
this->button12->Text = L"+";
this->button12->UseVisualStyleBackColor = true;
this->button12->Click += gcnew System::EventHandler(this, &Form1::button12_Click);
//
// button13
//
this->button13->Location = System::Point(190, 112);
this->button13->Name = L"button13";
this->button13->Size = System::Size(34, 28);
this->button13->TabIndex = 20;
this->button13->Text = L"-";
this->button13->UseVisualStyleBackColor = true;
this->button13->Click += gcnew System::EventHandler(this, &Form1::button13_Click);
//
// button14
//
this->button14->Location = System::Point(190, 146);
this->button14->Name = L"button14";
this->button14->Size = System::Size(34, 28);
this->button14->TabIndex = 21;
this->button14->Text = L"/";
this->button14->UseVisualStyleBackColor = true;
this->button14->Click += gcnew System::EventHandler(this, &Form1::button14_Click);
//
// button16
//
this->button16->Location = System::Point(150, 146);
this->button16->Name = L"button16";
this->button16->Size = System::Size(34, 28);
this->button16->TabIndex = 23;
this->button16->Text = L"*";
this->button16->UseVisualStyleBackColor = true;
this->button16->Click += gcnew System::EventHandler(this, &Form1::button16_Click);
//
// button15
//
this->button15->Location = System::Point(150, 180);
this->button15->Name = L"button15";
this->button15->Size = System::Size(74, 28);
this->button15->TabIndex = 24;
this->button15->Text = L"Cofnij";
this->button15->UseVisualStyleBackColor = true;
this->button15->Click += gcnew System::EventHandler(this, &Form1::button15_Click);
//
// button17
//
this->button17->Location = System::Point(150, 214);
this->button17->Name = L"button17";
this->button17->Size = System::Size(74, 28);
this->button17->TabIndex = 25;
this->button17->Text = L"Wyczysc";
this->button17->UseVisualStyleBackColor = true;
this->button17->Click += gcnew System::EventHandler(this, &Form1::button17_Click);
//
// Form1
//
this->AutoScaleDimensions = System::SizeF(6, 13);
this->AutoScaleMode = System::Font;
this->BackColor = System::Control;
this->ClientSize = System::Size(244, 262);
this->Controls->Add(this->button17);
this->Controls->Add(this->button15);
this->Controls->Add(this->button16);
this->Controls->Add(this->button14);
this->Controls->Add(this->button13);
this->Controls->Add(this->button12);
this->Controls->Add(this->button11);
this->Controls->Add(this->button10);
this->Controls->Add(this->button9);
this->Controls->Add(this->button8);
this->Controls->Add(this->button7);
this->Controls->Add(this->button6);
this->Controls->Add(this->button5);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Controls->Add(this->label3);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->radioButton2);
this->Controls->Add(this->radioButton1);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Name = L"Form1";
this->Text = L"Kalkulator";
this->ResumeLayout(false);
this->PerformLayout();

	}

#pragma endregion
private: System::Void label1_Click(System::Object sender, System::EventArgs e) {
}
// OPERACJA DODAWANIA:
private: System::Void button12_Click(System::Object sender, System::EventArgs e) {
System::Double wy1 = System::Parse(textBox1->Text) +
System::Parse(textBox2 ->Text);
textBox3->Text = wy1.ToString();
}
// OPERACJA ODEJMOWANIA
private: System::Void button13_Click(System::Object sender, System::EventArgs e) {
System::Double wy1 = System::Parse(textBox1->Text) -
System::Parse(textBox2 ->Text);
textBox3->Text = wy1.ToString();
}
// OPERACJA MNOŻENIA
private: System::Void button16_Click(System::Object sender, System::EventArgs e) {
System::Double wy1 = System::Parse(textBox1->Text) *
System::Parse(textBox2 ->Text);
textBox3->Text = wy1.ToString();
}
// OPERACJA DZIELENIA
private: System::Void button14_Click(System::Object sender, System::EventArgs e) {
System::Double wy1 = System::Parse(textBox1->Text) /
System::Parse(textBox2 ->Text);
textBox3->Text = wy1.ToString();
}
// ODCZYT KOLEJNYCH CYFR Z PRZYCISKÓW I WPISANIE ICH DO POLA
// PRZY KTÓRYM ZAZNACZONY JEST RADIOBUTTON:

private: System::Void button1_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText("1") ;
else
textBox2->AppendText("1") ;
}
private: System::Void button2_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText("2") ;
else
textBox2->AppendText("2") ;
}
private: System::Void button3_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText("3") ;
else
textBox2->AppendText("3") ;
}
private: System::Void button4_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText("4") ;
else
textBox2->AppendText("4") ;
}
private: System::Void button5_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText("5") ;
else
textBox2->AppendText("5") ;
}
private: System::Void button6_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText("6") ;
else
textBox2->AppendText("6") ;
}
private: System::Void button7_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText("7") ;
else
textBox2->AppendText("7") ;
}
private: System::Void button8_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText("8") ;
else
textBox2->AppendText("8") ;
}
private: System::Void button9_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText("9") ;
else
textBox2->AppendText("9") ;
}
private: System::Void button10_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText(",") ;
else
textBox2->AppendText(",") ;
}
private: System::Void button11_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->AppendText("0") ;
else
textBox2->AppendText("0") ;
}
// CZYSZCZENIE WSZYSTKICH PÓL
private: System::Void button17_Click(System::Object sender, System::EventArgs e) {
textBox1->Text = "";
textBox2->Text = "";
textBox3->Text = "";
}
// KASOWANIE OSTATNIEGO ZNAKU
private: System::Void button15_Click(System::Object sender, System::EventArgs e) {
if (radioButton1->Checked)
textBox1->Text = textBox1->Text->Substring(0, textBox1->Text->Length - 1);
else
textBox2->Text = textBox2->Text->Substring(0, textBox2->Text->Length - 1);
}
};
}

problem jest tego typu że mogę dodać dwa przecinki a chciałabym aby po pierwszym nie udało sie dodać drugiego, oraz gdy nacisnę jakikolwiek znak działania wyskakuje mi to co można zobaczyć w załączniku

0

nawet tego nie sprawdzam (wrzuć to do

   <\code>) jeżeli chodzi o sprawdzanie przecinku to na keypress (albo keydown, nie pamietam, ale raczej keypress) sprawdzaj czy w textboxie jest już przecinek/kropka. Jeżeli tak to nie pozwalaj

masz jasno napisane czemu Ci taki błąd występuje.

1 użytkowników online, w tym zalogowanych: 0, gości: 1