java
2015年12月11日 星期五
2015年11月20日 星期五
2015年11月5日 星期四
計算機
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 Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) + Double.Parse(textBox2.Text));
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) - Double.Parse(textBox2.Text));
}
private void button3_Click(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) * Double.Parse(textBox2.Text));
}
private void button4_Click(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) / Double.Parse(textBox2.Text));
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged_1(object sender, EventArgs e)
{
}
private void button1_Click_1(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) + Double.Parse(textBox2.Text));
}
private void button2_Click_1(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) - Double.Parse(textBox2.Text));
}
private void button3_Click_1(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) * Double.Parse(textBox2.Text));
}
private void button4_Click_1(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) / Double.Parse(textBox2.Text));
}
}
}
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 Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) + Double.Parse(textBox2.Text));
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) - Double.Parse(textBox2.Text));
}
private void button3_Click(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) * Double.Parse(textBox2.Text));
}
private void button4_Click(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) / Double.Parse(textBox2.Text));
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged_1(object sender, EventArgs e)
{
}
private void button1_Click_1(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) + Double.Parse(textBox2.Text));
}
private void button2_Click_1(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) - Double.Parse(textBox2.Text));
}
private void button3_Click_1(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) * Double.Parse(textBox2.Text));
}
private void button4_Click_1(object sender, EventArgs e)
{
textBox3.Text = System.Convert.ToString(Double.Parse(textBox1.Text) / Double.Parse(textBox2.Text));
}
}
}
2015年10月30日 星期五
4*4路數不重複
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 WindowsFormsApplication4
{
public partial class Form1 : Form
{Button[,] Buttons = new System.Windows.Forms.Button[5, 5];
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i < 5; i++ )
{
for (int j = 1; j < 5; j++ )
{
Buttons[i, j] = new Button();
Buttons[i, j].Size = new Size(50, 50);
Buttons[i, j].Location = new Point(i * 50, j * 50);
this.Controls.Add(Buttons[i, j]);//出現在畫面中
}
}
}
private void button1_Click(object sender, EventArgs e)
{
int pro = 0;
for (int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
pro = pro+1 ;
Buttons[i, j].Text = pro.ToString();
}
}
}
}
}
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 WindowsFormsApplication4
{
public partial class Form1 : Form
{Button[,] Buttons = new System.Windows.Forms.Button[5, 5];
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i < 5; i++ )
{
for (int j = 1; j < 5; j++ )
{
Buttons[i, j] = new Button();
Buttons[i, j].Size = new Size(50, 50);
Buttons[i, j].Location = new Point(i * 50, j * 50);
this.Controls.Add(Buttons[i, j]);//出現在畫面中
}
}
}
private void button1_Click(object sender, EventArgs e)
{
int pro = 0;
for (int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
pro = pro+1 ;
Buttons[i, j].Text = pro.ToString();
}
}
}
}
}
2015年10月23日 星期五
亂數不重複
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
{
int rndmoney1 = 0;
int rndmoney2 = 0;
int rndmoney3 = 0;
int rndmoney4 = 0;
int rndmoney5 = 0;
int rndmoney6 = 0;
int rndmoney7 = 0;
int rndmoney8 = 0;
int rndmoney9 = 0;
public Form1()
{
InitializeComponent();
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
button5.Enabled = false;
button6.Enabled = false;
button7.Enabled = false;
button8.Enabled = false;
button9.Enabled = false;
}
private void button10_Click(object sender, EventArgs e)
{
Random rnd = new Random();
rndmoney1 = rnd.Next(0, 9); // creates a number between 1 and 9
rndmoney2 = rnd.Next(0, 9); // creates a number between 1 and 9
//rndmoney3 = rnd.Next(0, 9); // creates a number between 1 and 9
//rndmoney4 = rnd.Next(0, 10); // creates a number between 1 and 9
//rndmoney5 = rnd.Next(0, 10); // creates a number between 1 and 9
//rndmoney6 = rnd.Next(0, 10); // creates a number between 1 and 9
//rndmoney7 = rnd.Next(0, 10); // creates a number between 1 and 9
//rndmoney8 = rnd.Next(0, 10); // creates a number between 1 and 9
//rndmoney9 = rnd.Next(0, 10); // creates a number between 1 and 9
button1.Text = rndmoney1.ToString();
button2.Text = rndmoney2.ToString();
if (rndmoney1 == rndmoney2)
{
MessageBox.Show("Dot Net Perls is awesome.");
rndmoney2 = rnd.Next(0, 9); // creates a number between 1 and 9
button2.Text = rndmoney2.ToString();
}
//button3.Text = rndmoney3.ToString();
//button4.Text = rndmoney4.ToString();
//button5.Text = rndmoney5.ToString();
//button6.Text = rndmoney6.ToString();
//button7.Text = rndmoney7.ToString();
//button8.Text = rndmoney8.ToString();
//button9.Text = rndmoney9.ToString();
//button10.Enabled = false;
}
}
}
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
{
int rndmoney1 = 0;
int rndmoney2 = 0;
int rndmoney3 = 0;
int rndmoney4 = 0;
int rndmoney5 = 0;
int rndmoney6 = 0;
int rndmoney7 = 0;
int rndmoney8 = 0;
int rndmoney9 = 0;
public Form1()
{
InitializeComponent();
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
button5.Enabled = false;
button6.Enabled = false;
button7.Enabled = false;
button8.Enabled = false;
button9.Enabled = false;
}
private void button10_Click(object sender, EventArgs e)
{
Random rnd = new Random();
rndmoney1 = rnd.Next(0, 9); // creates a number between 1 and 9
rndmoney2 = rnd.Next(0, 9); // creates a number between 1 and 9
//rndmoney3 = rnd.Next(0, 9); // creates a number between 1 and 9
//rndmoney4 = rnd.Next(0, 10); // creates a number between 1 and 9
//rndmoney5 = rnd.Next(0, 10); // creates a number between 1 and 9
//rndmoney6 = rnd.Next(0, 10); // creates a number between 1 and 9
//rndmoney7 = rnd.Next(0, 10); // creates a number between 1 and 9
//rndmoney8 = rnd.Next(0, 10); // creates a number between 1 and 9
//rndmoney9 = rnd.Next(0, 10); // creates a number between 1 and 9
button1.Text = rndmoney1.ToString();
button2.Text = rndmoney2.ToString();
if (rndmoney1 == rndmoney2)
{
MessageBox.Show("Dot Net Perls is awesome.");
rndmoney2 = rnd.Next(0, 9); // creates a number between 1 and 9
button2.Text = rndmoney2.ToString();
}
//button3.Text = rndmoney3.ToString();
//button4.Text = rndmoney4.ToString();
//button5.Text = rndmoney5.ToString();
//button6.Text = rndmoney6.ToString();
//button7.Text = rndmoney7.ToString();
//button8.Text = rndmoney8.ToString();
//button9.Text = rndmoney9.ToString();
//button10.Enabled = false;
}
}
}
2015年10月16日 星期五
拉霸
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
{
int c1 = 0, b1 = 0;
int c2 = 0, b2 = 0;
int c3 = 0, b3 = 0;
int rndmoney1 = 100;
int rndmoney2 = 100;
int rndmoney3 = 100;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
if (c1 >= rndmoney1) timer1.Enabled = false;
{
}
if (b1 == 0)
{
//button1.BackColor = Color.Green;
//button2.BackColor = Color.Black;
//button3.BackColor = Color.Black;
}
else if (b1 == 1)
{
//button1.BackColor = Color.Black;
//button2.BackColor = Color.Yellow;
// button3.BackColor = Color.Black;
}
else if (b1 == 2)
{
//button1.BackColor = Color.Black;
// button2.BackColor = Color.Black;
// button3.BackColor = Color.Red;
}
c1 = c1 + 1;
b1 = c1 % 3;
button1.Text = c1.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
c1 = 0;
c2 = 0;
c3 = 0;
timer1.Enabled = true;
timer2.Enabled = true;
timer3.Enabled = true;
Random rnd = new Random();
rndmoney1 = rnd.Next(1, 10);
rndmoney2 = rnd.Next(1, 10);
rndmoney3 = rnd.Next(1, 10);
button4.Text = rndmoney1.ToString() + rndmoney2.ToString() + rndmoney3.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
}
private void timer2_Tick_1(object sender, EventArgs e)
{
if (c2 >= rndmoney2) timer2.Enabled = false;
{
}
if (b1 == 0)
{
//button1.BackColor = Color.Green;
//button2.BackColor = Color.Black;
//button3.BackColor = Color.Black;
}
else if (b1 == 1)
{
//button1.BackColor = Color.Black;
//button2.BackColor = Color.Yellow;
// button3.BackColor = Color.Black;
}
else if (b1 == 2)
{
//button1.BackColor = Color.Black;
// button2.BackColor = Color.Black;
// button3.BackColor = Color.Red;
}
c2 = c2 + 1;
b2 = c2 % 3;
button2.Text = c2.ToString();
}
private void timer3_Tick_1(object sender, EventArgs e)
{
if (c3 >= rndmoney3) timer3.Enabled = false;
{
}
if (b1 == 0)
{
//button1.BackColor = Color.Green;
//button2.BackColor = Color.Black;
//button3.BackColor = Color.Black;
}
else if (b1 == 1)
{
//button1.BackColor = Color.Black;
//button2.BackColor = Color.Yellow;
// button3.BackColor = Color.Black;
}
else if (b1 == 2)
{
//button1.BackColor = Color.Black;
// button2.BackColor = Color.Black;
// button3.BackColor = Color.Red;
}
c3 = c3 + 1;
b3 = c3 % 3;
button3.Text = c3.ToString();
}
}
}
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
{
int c1 = 0, b1 = 0;
int c2 = 0, b2 = 0;
int c3 = 0, b3 = 0;
int rndmoney1 = 100;
int rndmoney2 = 100;
int rndmoney3 = 100;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
if (c1 >= rndmoney1) timer1.Enabled = false;
{
}
if (b1 == 0)
{
//button1.BackColor = Color.Green;
//button2.BackColor = Color.Black;
//button3.BackColor = Color.Black;
}
else if (b1 == 1)
{
//button1.BackColor = Color.Black;
//button2.BackColor = Color.Yellow;
// button3.BackColor = Color.Black;
}
else if (b1 == 2)
{
//button1.BackColor = Color.Black;
// button2.BackColor = Color.Black;
// button3.BackColor = Color.Red;
}
c1 = c1 + 1;
b1 = c1 % 3;
button1.Text = c1.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
c1 = 0;
c2 = 0;
c3 = 0;
timer1.Enabled = true;
timer2.Enabled = true;
timer3.Enabled = true;
Random rnd = new Random();
rndmoney1 = rnd.Next(1, 10);
rndmoney2 = rnd.Next(1, 10);
rndmoney3 = rnd.Next(1, 10);
button4.Text = rndmoney1.ToString() + rndmoney2.ToString() + rndmoney3.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
}
private void timer2_Tick_1(object sender, EventArgs e)
{
if (c2 >= rndmoney2) timer2.Enabled = false;
{
}
if (b1 == 0)
{
//button1.BackColor = Color.Green;
//button2.BackColor = Color.Black;
//button3.BackColor = Color.Black;
}
else if (b1 == 1)
{
//button1.BackColor = Color.Black;
//button2.BackColor = Color.Yellow;
// button3.BackColor = Color.Black;
}
else if (b1 == 2)
{
//button1.BackColor = Color.Black;
// button2.BackColor = Color.Black;
// button3.BackColor = Color.Red;
}
c2 = c2 + 1;
b2 = c2 % 3;
button2.Text = c2.ToString();
}
private void timer3_Tick_1(object sender, EventArgs e)
{
if (c3 >= rndmoney3) timer3.Enabled = false;
{
}
if (b1 == 0)
{
//button1.BackColor = Color.Green;
//button2.BackColor = Color.Black;
//button3.BackColor = Color.Black;
}
else if (b1 == 1)
{
//button1.BackColor = Color.Black;
//button2.BackColor = Color.Yellow;
// button3.BackColor = Color.Black;
}
else if (b1 == 2)
{
//button1.BackColor = Color.Black;
// button2.BackColor = Color.Black;
// button3.BackColor = Color.Red;
}
c3 = c3 + 1;
b3 = c3 % 3;
button3.Text = c3.ToString();
}
}
}
2015年10月2日 星期五
程式設計工藝大師
紅綠燈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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
int c = 0, d = 0;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
button1.BackColor = Color.WhiteSmoke;
button2.BackColor = Color.WhiteSmoke;
button3.BackColor = Color.WhiteSmoke;
c++;
d = c % 3;
if (d == 1)
{
button1.BackColor = Color.Red;
button2.BackColor = Color.White;
button3.BackColor = Color.White;
}
else if (d == 2)
{
button1.BackColor = Color.White;
button2.BackColor = Color.Yellow;
button3.BackColor = Color.White;
}
else if (d == 0)
{
button1.BackColor = Color.White;
button2.BackColor = Color.White;
button3.BackColor = Color.Green;
}
//button1.Text = c.ToString() ;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}
訂閱:
文章 (Atom)