私はC ++にかなり慣れていないので、仮想クレジット計算機を書いています! これが私のコードです:
PS: 私はドイツ人なので、ドイツ語の単語がいくつかあるかもしれませんが、そうは思いません!
#pragma once
namespace HypothekenRechner {
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
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
int Year [100];
int Mone[100];
int Interes[100];
int Redemptio[100];
int c;
int Money;
int Percent;
int Interest;
int tp;
int Redemption;
public:
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::TextBox^ textBox5;
private: System::Windows::Forms::TextBox^ textBox6;
private: System::Windows::Forms::TextBox^ textBox7;
private: System::Windows::Forms::TextBox^ textBox8;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::Label^ label9;
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::TextBox^ textBox3;
private: System::Windows::Forms::TextBox^ textBox4;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
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)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->textBox4 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->textBox5 = (gcnew System::Windows::Forms::TextBox());
this->textBox6 = (gcnew System::Windows::Forms::TextBox());
this->textBox7 = (gcnew System::Windows::Forms::TextBox());
this->textBox8 = (gcnew System::Windows::Forms::TextBox());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->label8 = (gcnew System::Windows::Forms::Label());
this->label9 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(158, 12);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(100, 20);
this->textBox1->TabIndex = 0;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(158, 38);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(100, 20);
this->textBox2->TabIndex = 1;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(158, 64);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(100, 20);
this->textBox3->TabIndex = 2;
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(158, 90);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(100, 20);
this->textBox4->TabIndex = 3;
//
// label1
//
this->label1->AutoSize = true;
this->label1->BackColor = System::Drawing::Color::Transparent;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->ForeColor = System::Drawing::Color::Black;
this->label1->Location = System::Drawing::Point(1, 14);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(79, 18);
this->label1->TabIndex = 4;
this->label1->Text = L"Hypothek";
//
// label2
//
this->label2->AutoSize = true;
this->label2->BackColor = System::Drawing::Color::Transparent;
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label2->ForeColor = System::Drawing::Color::Black;
this->label2->Location = System::Drawing::Point(1, 40);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(72, 18);
this->label2->TabIndex = 5;
this->label2->Text = L"Zinssatz";
//
// label3
//
this->label3->AutoSize = true;
this->label3->BackColor = System::Drawing::Color::Transparent;
this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label3->ForeColor = System::Drawing::Color::Black;
this->label3->Location = System::Drawing::Point(1, 66);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(140, 18);
this->label3->TabIndex = 6;
this->label3->Text = L"Jährliche Zahlung";
//
// label4
//
this->label4->AutoSize = true;
this->label4->BackColor = System::Drawing::Color::Transparent;
this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label4->ForeColor = System::Drawing::Color::Black;
this->label4->Location = System::Drawing::Point(1, 92);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(62, 18);
this->label4->TabIndex = 7;
this->label4->Text = L"Tilgung";
//
// label5
//
this->label5->AutoSize = true;
this->label5->BackColor = System::Drawing::Color::Transparent;
this->label5->Font = (gcnew System::Drawing::Font(L"Segoe Script", 24, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label5->ForeColor = System::Drawing::Color::Black;
this->label5->Location = System::Drawing::Point(12, 238);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(256, 53);
this->label5->TabIndex = 8;
this->label5->Text = L"Tobias Rohde";
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button1->ForeColor = System::Drawing::SystemColors::ControlText;
this->button1->Location = System::Drawing::Point(338, 248);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(150, 40);
this->button1->TabIndex = 9;
this->button1->Text = L"Berechnen";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// textBox5
//
this->textBox5->Location = System::Drawing::Point(388, 12);
this->textBox5->Name = L"textBox5";
this->textBox5->Size = System::Drawing::Size(100, 20);
this->textBox5->TabIndex = 10;
//
// textBox6
//
this->textBox6->Location = System::Drawing::Point(388, 41);
this->textBox6->Name = L"textBox6";
this->textBox6->Size = System::Drawing::Size(100, 20);
this->textBox6->TabIndex = 11;
//
// textBox7
//
this->textBox7->Location = System::Drawing::Point(388, 67);
this->textBox7->Name = L"textBox7";
this->textBox7->Size = System::Drawing::Size(100, 20);
this->textBox7->TabIndex = 12;
//
// textBox8
//
this->textBox8->Location = System::Drawing::Point(388, 92);
this->textBox8->Name = L"textBox8";
this->textBox8->Size = System::Drawing::Size(100, 20);
this->textBox8->TabIndex = 13;
//
// label6
//
this->label6->AutoSize = true;
this->label6->BackColor = System::Drawing::Color::Transparent;
this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label6->ForeColor = System::Drawing::Color::Black;
this->label6->Location = System::Drawing::Point(282, 14);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(41, 18);
this->label6->TabIndex = 14;
this->label6->Text = L"Jahr";
//
// label7
//
this->label7->AutoSize = true;
this->label7->BackColor = System::Drawing::Color::Transparent;
this->label7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label7->ForeColor = System::Drawing::Color::Black;
this->label7->Location = System::Drawing::Point(282, 43);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(92, 18);
this->label7->TabIndex = 15;
this->label7->Text = L"Restschuld";
//
// label8
//
this->label8->AutoSize = true;
this->label8->BackColor = System::Drawing::Color::Transparent;
this->label8->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label8->ForeColor = System::Drawing::Color::Black;
this->label8->Location = System::Drawing::Point(282, 69);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(58, 18);
this->label8->TabIndex = 16;
this->label8->Text = L"Zinsen";
//
// label9
//
this->label9->AutoSize = true;
this->label9->BackColor = System::Drawing::Color::Transparent;
this->label9->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label9->ForeColor = System::Drawing::Color::Black;
this->label9->Location = System::Drawing::Point(282, 94);
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(62, 18);
this->label9->TabIndex = 17;
this->label9->Text = L"Tilgung";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"$this.BackgroundImage")));
this->ClientSize = System::Drawing::Size(500, 300);
this->Controls->Add(this->label9);
this->Controls->Add(this->label8);
this->Controls->Add(this->label7);
this->Controls->Add(this->label6);
this->Controls->Add(this->textBox8);
this->Controls->Add(this->textBox7);
this->Controls->Add(this->textBox6);
this->Controls->Add(this->textBox5);
this->Controls->Add(this->button1);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox4);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Name = L"Form1";
this->Text = L"Hypotheken Rechner by Tobias Rohde";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
for(c=0;c<100;c++){
Money=Money-Redemption;
Mone[c]=Money;
Interes[c]=Money*Percent/100;
Redemption = tp-Zinse[c]; //tp to pay
Redemptio[c]=Redemption;
}
for(c=0;c<100;c++){
textBox5->Text = Year[c];
textBox6->Text = Mone[c];
textBox7->Text = Interes[c];
textBox8->Text = Redemptio[c];
if(Mone[c]<=0)
{
break;
}
}
}
};
}
このエラーが発生しています:
1>------ Build started: Project: Hypotheken Rechner, Configuration: Debug Win32 ------
1> Hypotheken Rechner.cpp
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(17): error C4368: cannot define 'Year' as a member of managed 'HypothekenRechner::Form1': mixed types are not supported
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(18): error C4368: cannot define 'Mone' as a member of managed 'HypothekenRechner::Form1': mixed types are not supported
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(19): error C4368: cannot define 'Interes' as a member of managed 'HypothekenRechner::Form1': mixed types are not supported
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(20): error C4368: cannot define 'Redemptio' as a member of managed 'HypothekenRechner::Form1': mixed types are not supported
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(319): error C2039: 'Form1_Load' : is not a member of 'HypothekenRechner::Form1'
1> c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(15) : see declaration of 'HypothekenRechner::Form1'
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(319): error C2065: 'Form1_Load' : undeclared identifier
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(319): error C3350: 'System::EventHandler' : a delegate constructor expects 2 argument(s)
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(332): error C2065: 'Zinse' : undeclared identifier
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(336): error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'int' to 'System::String ^'
1> No user-defined-conversion operator available, or
1> No standard conversion exists from the boxed form of the arithmetic type to the target type
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(337): error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'int' to 'System::String ^'
1> No user-defined-conversion operator available, or
1> No standard conversion exists from the boxed form of the arithmetic type to the target type
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(338): error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'int' to 'System::String ^'
1> No user-defined-conversion operator available, or
1> No standard conversion exists from the boxed form of the arithmetic type to the target type
1>c:\users\tobi\documents\visual studio 2010\projects\hypotheken rechner\hypotheken rechner\Form1.h(339): error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'int' to 'System::String ^'
1> No user-defined-conversion operator available, or
1> No standard conversion exists from the boxed form of the arithmetic type to the target type
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
私はこれを修正するために多くのことを試しました。コンストラクターでいくつかの宣言を取得することと、マネージドおよび静的なものに関するいくつかのことについて多くのことを読みました...これを修正するのを手伝ってください!