建立一個簡單的MS Visual Studio GUI C++ 程式碼

MyForm.cpp
#include "MyForm.h"
#include <stdlib.h>
//using namespace 物件名(專案名);
using namespace ProjectForm05;
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
//int main(array<System::String ^> ^args)
int main(array<String^> ^args)
//int main()
{
//視窗化
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
ProjectForm05::MyForm form;
Application::Run(%form);

//程式

//執行視窗介面
Application::Run(gcnew MyForm());
return 0;
}
MyForm.h
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

String ^ in = textBox1->Text;
int ini = System::Convert::ToInt16(in);

int fact = 1;
for (int i = 1; i <= ini; i++)
{
fact = fact*i;
}

in = System::Convert::ToString(fact);
label3->Text = in;

}
已邀請:

要回復主題請先登入註冊