#pragma once


namespace LoopStyle {

	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>
	/// Form1 的摘要
	///
	/// 警告: 如果您變更這個類別的名稱，就必須變更與這個類別所依據之所有 .resx 檔案關聯的
	///          Managed 資源編譯器工具的 'Resource File Name' 屬性。
	///          否則，這些設計工具
	///          將無法與這個表單關聯的當地語系化資源
	///          正確互動。
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: 在此加入建構函式程式碼
			//
		}

	protected:
		/// <summary>
		/// 清除任何使用中的資源。
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  button1;
	protected: 
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::Button^  button2;
	private: System::Windows::Forms::Button^  button3;
	private: System::Windows::Forms::TextBox^  textBox1;
	private: System::Windows::Forms::Button^  button4;
	private: System::Windows::Forms::Button^  button5;

	private:
		/// <summary>
		/// 設計工具所需的變數。
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改這個方法的內容。
		///
		/// </summary>
		void InitializeComponent(void)
		{
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->button3 = (gcnew System::Windows::Forms::Button());
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
			this->button4 = (gcnew System::Windows::Forms::Button());
			this->button5 = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(12, 64);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(107, 23);
			this->button1->TabIndex = 0;
			this->button1->Text = L"For 迴圈";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(24, 298);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(33, 12);
			this->label1->TabIndex = 1;
			this->label1->Text = L"label1";
			// 
			// button2
			// 
			this->button2->Location = System::Drawing::Point(12, 111);
			this->button2->Name = L"button2";
			this->button2->Size = System::Drawing::Size(107, 23);
			this->button2->TabIndex = 2;
			this->button2->Text = L"計算2的倍數";
			this->button2->UseVisualStyleBackColor = true;
			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
			// 
			// button3
			// 
			this->button3->Location = System::Drawing::Point(12, 151);
			this->button3->Name = L"button3";
			this->button3->Size = System::Drawing::Size(107, 23);
			this->button3->TabIndex = 3;
			this->button3->Text = L"Break的運用";
			this->button3->UseVisualStyleBackColor = true;
			this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(139, 153);
			this->textBox1->Name = L"textBox1";
			this->textBox1->Size = System::Drawing::Size(100, 22);
			this->textBox1->TabIndex = 4;
			// 
			// button4
			// 
			this->button4->Location = System::Drawing::Point(12, 194);
			this->button4->Name = L"button4";
			this->button4->Size = System::Drawing::Size(107, 23);
			this->button4->TabIndex = 5;
			this->button4->Text = L"Do While";
			this->button4->UseVisualStyleBackColor = true;
			this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
			// 
			// button5
			// 
			this->button5->Location = System::Drawing::Point(12, 241);
			this->button5->Name = L"button5";
			this->button5->Size = System::Drawing::Size(107, 23);
			this->button5->TabIndex = 6;
			this->button5->Text = L"While Do";
			this->button5->UseVisualStyleBackColor = true;
			this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(408, 367);
			this->Controls->Add(this->button5);
			this->Controls->Add(this->button4);
			this->Controls->Add(this->textBox1);
			this->Controls->Add(this->button3);
			this->Controls->Add(this->button2);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->button1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 int i;
				 String ^str1;
				 for (i=1;i<=5;i++)
				 {
					 str1=str1+Convert::ToString(i);
				 }

				 label1->Text=str1;
				 
			 }
	private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
                 int i;
				 String ^str1;
				 for (i=1;i<=10;i++)
				 {
					 if(i % 2 ==0)
					 {
					  str1=str1+Convert::ToString(i);
					 }
					 
				 }

				 label1->Text=str1;
				 
			 }
	private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
                 int i,j;
				 String ^str1;
				 str1=textBox1->Text;
                 j=Convert::ToInt32(str1);
				 str1="";
				 for (i=1;i<=j;i++)
				 {
					 if (i>20){
					   break;
					 }else{
                       str1=str1+Convert::ToString(i);
					 
					 }//end if
				 }//end for

                 label1->Text=str1;

			 }
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
			 int i ;
			 String ^str1;
			 do {
				 i++;
                 str1=str1+Convert::ToString(i);		 
			 }while (i<=20);
              label1->Text=str1; 

		 }
private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {

			 int i ;
			 String ^str1;
			 while (i<20) {
				 i++;
                 str1=str1+Convert::ToString(i);	 
			 
			 }//end while
			 label1->Text=str1; 

		 }
};
}

