Private Sub CommandButton1_Click()
Application.ActiveSheet.Cells(1, 1).Value = "Excel VBA 99乘法表"
For C = 1 To 9
Application.Cells(1, C).ColumnWidth = 3
Next
For I = 1 To 9
For J = 1 To 9
Application.ActiveSheet.Cells(I + 1, J).Value = I * J
Next
Next
End Sub
Private Sub UserForm_Click()
End Sub

1415948508-1260397940_n  

a7342068 發表在 痞客邦 留言(0) 人氣()

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        int b1, r1,r2,r3,r4,r5,r6,r7,r8,r9;
        public Form1()
        {
            InitializeComponent();
            
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            button1.Text = "";
            button2.Text = "";
            button3.Text = "";
            button4.Text = "";
            button5.Text = "";
            button6.Text = "";
            button7.Text = "";
            button8.Text = "";
            button9.Text = "";
        }
        private void judge()
        {
            if (button1.Text == "X" && button2.Text == "X" && button3.Text == "X")
            {
                MessageBox.Show ( "X贏了");
            }
            else if(button4.Text == "X" && button5.Text == "X" && button6.Text == "X")
            {
                MessageBox.Show ("X贏了");
            }
            else if (button7.Text == "X" && button8.Text == "X" && button9.Text =="X")
            {
                MessageBox.Show("X贏了");
            }
            else if (button1.Text == "X" && button4.Text == "X" && button7.Text == "X")
            {
                MessageBox.Show("X贏了");
            }
            else if (button2.Text == "X" && button5.Text == "X" && button8.Text == "X")
            {
                MessageBox.Show("X贏了");
            }
            else if (button3.Text == "X" && button6.Text == "X" && button9.Text == "X")
            {
                MessageBox.Show("X贏了");
            }
            else if (button1.Text == "X" && button5.Text == "X" && button9.Text == "X")
            {
                MessageBox.Show("X贏了");
            }
            else if (button3.Text == "X" && button5.Text == "X" && button7.Text == "X")
            {
                MessageBox.Show("X贏了");
            }
            else if (button1.Text == "O" && button2.Text == "O" && button3.Text=="O")
            {
                MessageBox.Show("O贏了");
            }
            else if (button4.Text == "O" && button5.Text == "O" && button6.Text == "O")
            {
                MessageBox.Show("O贏了");
            }
            else if (button7.Text == "O" && button8.Text == "O" && button9.Text == "O")
            {
                MessageBox.Show("O贏了");
            }
            else if (button1.Text == "O" && button4.Text == "O" && button7.Text == "O")
            {
                MessageBox.Show("O贏了");
            }
            else if (button2.Text == "O" && button5.Text == "O" && button8.Text == "O")
            {
                MessageBox.Show("O贏了");
            }
            else if (button3.Text == "O" && button6.Text == "O" && button9.Text == "O")
            {
                MessageBox.Show("O贏了");
            }
            else if (button1.Text == "O" && button5.Text == "O" && button9.Text == "O")
            {
                MessageBox.Show("O贏了");
            }
            else if (button3.Text == "O" && button5.Text == "O" && button7.Text == "O")
            {
                MessageBox.Show("O贏了");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            b1 = b1 + 1;
            r1 = b1 % 2;
            if (r1 == 0)
            {
                button1.Text = "O";
            }
            else
            {
                button1.Text = "X";
            }
            button1.Enabled = false;
            textBox1.Text = Convert.ToString(r1);
            judge();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            b1 = b1 + 1;
            r2 = b1 % 2;
            if (r2 == 0)
            {
                button2.Text = "O";
            }
            else
            {
                button2.Text = "X";
            }
            button2.Enabled = false;
            textBox1.Text = Convert.ToString(r2);
            judge();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            b1 = b1 + 1;
            r3 = b1 % 2;
            if (r3 == 0)
            {
                button3.Text = "O";
            }
            else
            {
                button3.Text = "X";
            }
            button3.Enabled = false;
            textBox1.Text = Convert.ToString(r3);
            judge();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            b1 = b1 + 1;
            r4 = b1 % 2;
            if (r4 == 0)
            {
                button4.Text = "O";
            }
            else
            {
                button4.Text = "X";
            }
            button4.Enabled = false;
            textBox1.Text = Convert.ToString(r4);
            judge();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            b1 = b1 + 1;
            r5 = b1 % 2;
            if (r5 == 0)
            {
                button5.Text = "O";
            }
            else
            {
                button5.Text = "X";
            }
            button5.Enabled = false;
            textBox1.Text = Convert.ToString(r5);
            judge();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            b1 = b1 + 1;
            r6 = b1 % 2;
            if (r6 == 0)
            {
                button6.Text = "O";
            }
            else
            {
                button6.Text = "X";
            }
            button6.Enabled = false;
            textBox1.Text = Convert.ToString(r6);
            judge();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            b1 = b1 + 1;
            r7 = b1 % 2;
            if (r7 == 0)
            {
                button7.Text = "O";
            }
            else
            {
                button7.Text = "X";
            }
            button7.Enabled = false;
            textBox1.Text = Convert.ToString(r7);
            judge();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            b1 = b1 + 1;
            r8 = b1 % 2;
            if (r8 == 0)
            {
                button8.Text = "O";
            }
            else
            {
                button8.Text = "X";
            }
            button8.Enabled = false;
            textBox1.Text = Convert.ToString(r8);
            judge();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            b1 = b1 + 1;
            r9 = b1 % 2;
            if (r9 == 0)
            {
                button9.Text = "O";
            }
            else
            {
                button9.Text = "X";
            }


            button9.Enabled = false;
            textBox1.Text = Convert.ToString(r9);
            judge();
        }

        
    }
}

a7342068 發表在 痞客邦 留言(0) 人氣()

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int c;
int d = 1;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
button1.Left = 100*c;
if(button1.Left>460)
{
d = -1;
}
if (button1.Left < 0)
{
d = 1;
}
c = c + d;
}
}
}


a7342068 發表在 痞客邦 留言(0) 人氣()


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication7
{
    public partial class Form1 : Form
    {
        int a=0,b;
        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            a = a + 1;
            b = a % 3;
            if (b == 1)
            {
                button1.BackColor = Color.Red;
                button2.BackColor = Color.Black;
                button3.BackColor = Color.Black;
            }
            else if (b == 2)
            {
                button1.BackColor = Color.Black;
                button2.BackColor = Color.Yellow;
                button3.BackColor = Color.Black;
            }
            else
            {
                button1.BackColor = Color.Black;
                button2.BackColor = Color.Black;
                button3.BackColor = Color.Green;
            }
        }
    }
}

紅綠燈  

a7342068 發表在 痞客邦 留言(0) 人氣()

«123