martes, 17 de noviembre de 2009

EXTRA 1 VISUAL

VISUAL

namespace examen_1
{
public partial class Form1 : Form
{
int valor, sum, n;
double prom;

public Form1()
{
InitializeComponent();
sum = n = valor = 0;
listBox1.Items.Add("Valores Numericos:");
listBox1.Items.Add(" ");
}
private void button1_Click(object sender, EventArgs e)
{
valor = int.Parse(textBox1.Text);
if (valor != 9999)
{
listBox1.Items.Add("" + valor.ToString());
sum = sum + valor;
n = n + 1;
textBox1.Clear();
textBox1.Focus();
}
else
{
n = n - 1;
prom = sum / n;
listBox1.Items.Add(" ");
listBox1.Items.Add("El Promedio Es: "+ prom.ToString());
textBox1.Enabled = false;
button1.Enabled = false;
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
listBox1.Items.Clear();
textBox1.Enabled = true;
button1.Enabled = true;
textBox1.Focus();
}

private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}

No hay comentarios:

Publicar un comentario