lunes, 19 de abril de 2010

Practica 9 Problema 2 "En visual"

Codigo:

namespace practica_9_problema_2_visual
{
public partial class Form1 : Form
{
int[] corriente;
int[] resistencia;
int[] voltaje;
int i;
public Form1()
{
InitializeComponent();
corriente = new int[10];
resistencia = new int[10];
voltaje = new int[10];
listBox1.Items.Add("Corriente\t\tResistencia\tVoltios");
Console.WriteLine(" ");
i = 0;
}

private void button1_Click(object sender, EventArgs e)
{


if (i < 10)
{
corriente[i] = int.Parse(textBox1.Text);
resistencia[i] = int.Parse(textBox2.Text);
textBox1.Clear();
textBox2.Clear();
textBox2.Focus();
textBox2.Focus();
i++;

}
if (i == 10)
{
textBox1.Enabled = false;
textBox2.Enabled = false;
button1.Enabled = false;
}
}

private void button2_Click(object sender, EventArgs e)
{
for (i = 0; i < 10; i = i + 1)
{
voltaje[i] = corriente[i] * resistencia[i];


listBox1.Items.Add(corriente[i] + "\t\t"+ resistencia[i] + "\t\t" + voltaje[i]);

}

}

private void button3_Click(object sender, EventArgs e)
{
textBox1.Enabled = true;
textBox2.Enabled = true;
button1.Enabled = true;
listBox1.Items.Clear();
}

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

No hay comentarios:

Publicar un comentario