Martes, Pebrero 7, 2012
Act 2: lucky 9 requested
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
{
public Form1()
{
InitializeComponent();
}
private void btndraw_Click(object sender, EventArgs e)
{
int input;
if (txtinput1.Text == "")
{
MessageBox.Show("Enter a number from 1-9", "Lucky 9 ", MessageBoxButtons.OK, MessageBoxIcon.Error);
SendKeys.Send("{Home}+{End}");
txtinput1.Focus();
}
else
{
if (Int32.TryParse(txtinput1.Text, out input))
{
if (input > 9 || input <0) {
MessageBox.Show("Number's from 0-9 only", "Lucky 9 ", MessageBoxButtons.OK, MessageBoxIcon.Error);
SendKeys.Send("{Home}+{End}");
txtinput1.Focus();
}
else
{
Random rnd = new Random();
int random = rnd.Next(10);
lblout.Text = random.ToString();
if (input > random)
{
lblout2.Text = "You Win";
}
else if (input<random)
{
lblout2.Text = "You Lose!";
}
else
{
lblout2.Text = "DRAW!";
}
}
}
else
{
MessageBox.Show("Please enter number's from 0-9 only", "Lucky 9 ", MessageBoxButtons.OK, MessageBoxIcon.Error);
SendKeys.Send("{Home}+{End}");
txtinput1.Focus();
}
}
}
private void btn_Click(object sender, EventArgs e)
{
lblout.Text = "";
lblout2.Text = "";
txtinput1.Text = "";
SendKeys.Send("{Home}+{End}");
txtinput1.Focus();
}
private void btnexit_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are Your Sure?", "Lucky 9 ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
this.Close();
}
private void txtinput1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
btndraw_Click(null, null);
}
}
}
}
Mag-subscribe sa:
I-post ang Mga Komento (Atom)
Walang komento:
Mag-post ng isang Komento