티스토리 뷰

AU Study/TAFE

w5 fri morning

Last72 2017. 8. 23. 09:36
Windows forms application.



e.g. fizzbuzz
// Woongyeol_choi

// P453075

// 18/08/2017

// pizzbuzz



using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;



namespace Woongyeol_choi_p453075_windowsformsapp

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }



        private void Form1_Load(object sender, EventArgs e)

        {



        }



        private void button1_Click(object sender, EventArgs e)

        {

            int myNum = 0;

            bool answer = int.TryParse(textBox1.Text, out myNum);

            if (answer)

            {

                string outtext = "";

                if (myNum % 3 == 0)

                {

                    outtext += "Fizz";

                }

                if (myNum % 5 == 0)

                {

                    outtext += "Buzz";

                }

                if (outtext == "")

                {

                    outtext = myNum.ToString();

                }

                textBox2.Text = outtext;

            }else

            {

                textBox2.Text = "Please enter Interger.";

            }



        }



        private void label1_Click(object sender, EventArgs e)

        {

          

        }

    }

}





eg. listbox



// P453075



// 18/08/2017



// listbox



using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;



namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }



        private void button1_Click(object sender, EventArgs e)

        {



            listboxmydetails.Items.Add(textmyname.Text);

            textmyname.Clear();

        }

    }

}

e.g. Activity 26

// Woongyeol_choi

// P453075

// 18/08/2017

// Activity 26



using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;



namespace Woongyeol_choi_p453075_activity26

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }



        private void btnRunCode_Click(object sender, EventArgs e)

        {

            //Clear lists

            listOutput.Items.Clear();





            int num1 = 0;

            int num2 = 0;

            int sum, product;



            if (!((int.TryParse(textNumber1.Text, out num1)) && (int.TryParse(textNumber2.Text, out num2))))

            {

                listOutput.Items.Add("Please input correct interger.");

            }else

            {

                if(num1 > num2)

                {

                    listOutput.Items.Add("num1 is bigger than num2");

                }

                else

                {

                    listOutput.Items.Add("num2 is bigger than num1 or same.");

                }



                sum = num1 + num2;

                product = num1 * num2;



                listOutput.Items.Add("The sum is " + sum);

                listOutput.Items.Add("The product is " + product);





            }



        }

    }

}



/*

Button: btnRunCode

Label: Number1

Label: Number2

TextBox: textNumber1

TextBox: textNumber2

ListBox: listOutput

*/

'AU Study > TAFE' 카테고리의 다른 글

w6 Tue morning  (0) 2017.08.29
CMD line navigation  (0) 2017.08.29
w5 thu morning  (0) 2017.08.23
w5 wed morning  (0) 2017.08.23
w5 wed afternoon  (0) 2017.08.23
댓글
Announcement
Recent Posts
Recent Comments
Total
Today
Yesterday
Link
TAG
more
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Search by month