The game is to match the colour code of the resistor with a randomly pick value,
something like this...

basically The colour bands of the resistor shown above are using label. One can select/choose the colour of the band through the combo box
The value display at the output label beside the Random Resistor Value: is a randomly generated value,
The other value display at the label beside the Answer button is the selected combo box value
Once the selected combo box value is confirmed, press the Answer button to check if the answer is correct,Once the answer is correct, a messagebox displaying the word Correct will be shown and if the answer is wrong, the word Wrong will be displayed.
this is wat i have done so far...
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int OrangeRes = 1000;
int RedRes = 900;
int YellowRes = 1100;
int GreenRes = 1200;
int BlueRes = 1300;
int IndigoRes = 1400;
int GrayRes = 1500;
int WhiteRes = 1600;
if (comboBox1.SelectedIndex == 0)
{
lbl1stband.BackColor = Color.Red;
lblAnswer.Text = Convert.ToString(RedRes + "Ω +/- 10%");
}
else if (comboBox1.SelectedIndex == 1)
{
lbl1stband.BackColor = Color.Orange;
lblAnswer.Text = Convert.ToString(OrangeRes + "Ω +/- 10%");
}
else if (comboBox1.SelectedIndex == 2)
{
lbl1stband.BackColor = Color.Yellow;
lblAnswer.Text = Convert.ToString(YellowRes+ "Ω +/- 10%");
}
else if (comboBox1.SelectedIndex == 3)
{
lbl1stband.BackColor = Color.Green;
lblAnswer.Text = Convert.ToString(GreenRes + "Ω +/- 10%");
}
else if (comboBox1.SelectedIndex == 4)
{
lbl1stband.BackColor = Color.Blue;
lblAnswer.Text = Convert.ToString(BlueRes + "Ω +/- 10%");
}
else if (comboBox1.SelectedIndex == 5)
{
lbl1stband.BackColor = Color.Indigo;
lblAnswer.Text = Convert.ToString(IndigoRes + "Ω +/- 10%");
}
else if (comboBox1.SelectedIndex == 6)
{
lbl1stband.BackColor = Color.Gray;
lblAnswer.Text = Convert.ToString(GrayRes + "Ω +/- 10%");
}
else if (comboBox1.SelectedIndex == 7)
{
lbl1stband.BackColor = Color.White;
lblAnswer.Text = Convert.ToString(WhiteRes + "Ω +/- 10%");
}
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
int OrangeRes = 1000;
int RedRes = 900;
int YellowRes = 1100;
int GreenRes = 1200;
int BlueRes = 1300;
int IndigoRes = 1400;
int GrayRes = 1500;
int WhiteRes = 1600;
if (comboBox2.SelectedIndex == 0)
{
lbl2ndband.BackColor = Color.Red;
lblAnswer.Text = Convert.ToString(RedRes + "Ω +/- 10%");
}
else if (comboBox2.SelectedIndex == 1)
{
lbl2ndband.BackColor = Color.Orange;
lblAnswer.Text = Convert.ToString(OrangeRes + "Ω +/- 10%");
}
else if (comboBox2.SelectedIndex == 2)
{
lbl2ndband.BackColor = Color.Yellow;
lblAnswer.Text = Convert.ToString(YellowRes + "Ω +/- 10%");
}
else if (comboBox2.SelectedIndex == 3)
{
lbl2ndband.BackColor = Color.Green;
lblAnswer.Text = Convert.ToString(GreenRes + "Ω +/- 10%");
}
else if (comboBox2.SelectedIndex == 4)
{
lbl2ndband.BackColor = Color.Blue;
lblAnswer.Text = Convert.ToString(BlueRes + "Ω +/- 10%");
}
else if (comboBox2.SelectedIndex == 5)
{
lbl2ndband.BackColor = Color.Indigo;
lblAnswer.Text = Convert.ToString(IndigoRes + "Ω +/- 10%");
}
else if (comboBox2.SelectedIndex == 6)
{
lbl2ndband.BackColor = Color.Gray;
lblAnswer.Text = Convert.ToString(GrayRes + "Ω +/- 10%");
}
else if (comboBox2.SelectedIndex == 7)
{
lbl2ndband.BackColor = Color.White;
lblAnswer.Text = Convert.ToString(WhiteRes + "Ω +/- 10%");
}
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
int OrangeRes = 1000;
int RedRes = 900;
int YellowRes = 1100;
int GreenRes = 1200;
int BlueRes = 1300;
int IndigoRes = 1400;
int GrayRes = 1500;
int WhiteRes = 1600;
if (comboBox3.SelectedIndex == 0)
{
lbl3rdband.BackColor = Color.Red;
lblAnswer.Text = Convert.ToString(RedRes + "Ω +/- 10%");
}
else if (comboBox3.SelectedIndex == 1)
{
lbl3rdband.BackColor = Color.Orange;
lblAnswer.Text = Convert.ToString(OrangeRes + "Ω +/- 10%");
}
else if (comboBox3.SelectedIndex == 2)
{
lbl3rdband.BackColor = Color.Yellow;
lblAnswer.Text = Convert.ToString(YellowRes + "Ω +/- 10%");
}
else if (comboBox3.SelectedIndex == 3)
{
lbl3rdband.BackColor = Color.Green;
lblAnswer.Text = Convert.ToString(GreenRes + "Ω +/- 10%");
}
else if (comboBox3.SelectedIndex == 4)
{
lbl3rdband.BackColor = Color.Blue;
lblAnswer.Text = Convert.ToString(BlueRes + "Ω +/- 10%");
}
else if (comboBox3.SelectedIndex == 5)
{
lbl3rdband.BackColor = Color.Indigo;
lblAnswer.Text = Convert.ToString(IndigoRes + "Ω +/- 10%");
}
else if (comboBox3.SelectedIndex == 6)
{
lbl3rdband.BackColor = Color.Gray;
lblAnswer.Text = Convert.ToString(GrayRes + "Ω +/- 10%");
}
else if (comboBox3.SelectedIndex == 7)
{
lbl3rdband.BackColor = Color.White;
lblAnswer.Text = Convert.ToString(WhiteRes + "Ω +/- 10%");
}
}
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
{
int OrangeRes = 1000;
int RedRes = 900;
int YellowRes = 1100;
int GreenRes = 1200;
int BlueRes = 1300;
int IndigoRes = 1400;
int GrayRes = 1500;
int WhiteRes = 1600;
if (comboBox4.SelectedIndex == 0)
{
lbl4thband.BackColor = Color.Red;
lblAnswer.Text = Convert.ToString(RedRes + "Ω +/- 10%");
}
else if (comboBox4.SelectedIndex == 1)
{
lbl4thband.BackColor = Color.Orange;
lblAnswer.Text = Convert.ToString(OrangeRes + "Ω +/- 10%");
}
else if (comboBox4.SelectedIndex == 2)
{
lbl4thband.BackColor = Color.Yellow;
lblAnswer.Text = Convert.ToString(YellowRes + "Ω +/- 10%");
}
else if (comboBox4.SelectedIndex == 3)
{
lbl4thband.BackColor = Color.Green;
lblAnswer.Text = Convert.ToString(GreenRes + "Ω +/- 10%");
}
else if (comboBox4.SelectedIndex == 4)
{
lbl4thband.BackColor = Color.Blue;
lblAnswer.Text = Convert.ToString(BlueRes + "Ω +/- 10%");
}
else if (comboBox4.SelectedIndex == 5)
{
lbl4thband.BackColor = Color.Indigo;
lblAnswer.Text = Convert.ToString(IndigoRes + "Ω +/- 10%");
}
else if (comboBox4.SelectedIndex == 6)
{
lbl4thband.BackColor = Color.Gray;
lblAnswer.Text = Convert.ToString(GrayRes + "Ω +/- 10%");
}
else if (comboBox4.SelectedIndex == 7)
{
lbl4thband.BackColor = Color.White;
lblAnswer.Text = Convert.ToString(WhiteRes + "Ω +/- 10%");
}
Its in a big mess and i hope someone would check this out for me.
i can't figure out how to add the selected combobox's colour to another combobox's selected colour.
Edited by macosxnerd101: Welcome to DIC!

New Topic/Question
Reply




MultiQuote



|