hallo mensen ik heb een vraagje:
ik heb een programmatje gemaakt waarmee ik het gemiddelde cijfer kan uitreken van 8 leerlingen. hierbij heb ik gewoon 9 textboxes, in 8 van deze textboxes kan ik de cijfer van leerlingen in vullen en in de 9e textbox komt uiteindelijk het gemiddelde staan. maar het probleem is: nu wil ik voor elk textboxje waar je cijfers in moet vullen een checkbox hebben waarmee je ervoor kan zorgen dat het cijfer erachter 2x mee kan tellen... ik kom er alleen niet uit.
ik hoop dat jullie mij kunnen helpen.
btw. dit is c# en niet c++... ik kon C# namelijk niet vinden...
dit is mijn script:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace project
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click_1(object sender, EventArgs e)
{
double som, aantal;
double gemiddelde;
som = 0; aantal = 0; gemiddelde = 0;
for (int t2 = 1; t2 < 9; t2++)
{
if (textBox1.TabIndex == t2)
{
if (textBox1.Text != "")
{
if (Int32.Parse(textBox1.Text) > 0)
{
if (checkBox1.Checked)
som = som + Int32.Parse(textBox1.Text);
aantal++;
}
}
}
if (textBox2.TabIndex == t2)
{
if (textBox2.Text != "")
{
if (Int32.Parse(textBox2.Text) > 0)
{
som = som + Int32.Parse(textBox2.Text);
aantal++;
}
}
} if (textBox3.TabIndex == t2)
{
if (textBox3.Text != "")
{
if (Int32.Parse(textBox3.Text) > 0)
{
som = som + Int32.Parse(textBox3.Text);
aantal++;
}
}
} if (textBox4.TabIndex == t2)
{
if (textBox4.Text != "")
{
if (Int32.Parse(textBox4.Text) > 0)
{
som = som + Int32.Parse(textBox4.Text);
aantal++;
}
}
} if (textBox5.TabIndex == t2)
{
if (textBox5.Text != "")
{
if (Int32.Parse(textBox5.Text) > 0)
{
som = som + Int32.Parse(textBox5.Text);
aantal++;
}
}
} if (textBox6.TabIndex == t2)
{
if (textBox6.Text != "")
{
if (Int32.Parse(textBox6.Text) > 0)
{
som = som + Int32.Parse(textBox6.Text);
aantal++;
}
}
} if (textBox7.TabIndex == t2)
{
if (textBox7.Text != "")
{
if (Int32.Parse(textBox7.Text) > 0)
{
som = som + Int32.Parse(textBox7.Text);
aantal++;
}
}
} if (textBox8.TabIndex == t2)
{
if (textBox8.Text != "")
{
if (Int32.Parse(textBox8.Text) > 0)
{
som = som + Int32.Parse(textBox8.Text);
aantal++;
}
}
}
gemiddelde = som / aantal;
textBox10.Text = gemiddelde.ToString();
}
}
private void btnLeegmaken_Click_1(object sender, EventArgs e)
{
foreach (Control ctrl in this.tabPage1.Controls)
{
string typeCtrl = Convert.ToString(ctrl.GetType());
if (typeCtrl == "System.Windows.Forms.TextBox")
{
ctrl.Text = "";
}
}
}
private void stoppen_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
ik heb een programmatje gemaakt waarmee ik het gemiddelde cijfer kan uitreken van 8 leerlingen. hierbij heb ik gewoon 9 textboxes, in 8 van deze textboxes kan ik de cijfer van leerlingen in vullen en in de 9e textbox komt uiteindelijk het gemiddelde staan. maar het probleem is: nu wil ik voor elk textboxje waar je cijfers in moet vullen een checkbox hebben waarmee je ervoor kan zorgen dat het cijfer erachter 2x mee kan tellen... ik kom er alleen niet uit.
ik hoop dat jullie mij kunnen helpen.
btw. dit is c# en niet c++... ik kon C# namelijk niet vinden...
dit is mijn script:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace project
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click_1(object sender, EventArgs e)
{
double som, aantal;
double gemiddelde;
som = 0; aantal = 0; gemiddelde = 0;
for (int t2 = 1; t2 < 9; t2++)
{
if (textBox1.TabIndex == t2)
{
if (textBox1.Text != "")
{
if (Int32.Parse(textBox1.Text) > 0)
{
if (checkBox1.Checked)
som = som + Int32.Parse(textBox1.Text);
aantal++;
}
}
}
if (textBox2.TabIndex == t2)
{
if (textBox2.Text != "")
{
if (Int32.Parse(textBox2.Text) > 0)
{
som = som + Int32.Parse(textBox2.Text);
aantal++;
}
}
} if (textBox3.TabIndex == t2)
{
if (textBox3.Text != "")
{
if (Int32.Parse(textBox3.Text) > 0)
{
som = som + Int32.Parse(textBox3.Text);
aantal++;
}
}
} if (textBox4.TabIndex == t2)
{
if (textBox4.Text != "")
{
if (Int32.Parse(textBox4.Text) > 0)
{
som = som + Int32.Parse(textBox4.Text);
aantal++;
}
}
} if (textBox5.TabIndex == t2)
{
if (textBox5.Text != "")
{
if (Int32.Parse(textBox5.Text) > 0)
{
som = som + Int32.Parse(textBox5.Text);
aantal++;
}
}
} if (textBox6.TabIndex == t2)
{
if (textBox6.Text != "")
{
if (Int32.Parse(textBox6.Text) > 0)
{
som = som + Int32.Parse(textBox6.Text);
aantal++;
}
}
} if (textBox7.TabIndex == t2)
{
if (textBox7.Text != "")
{
if (Int32.Parse(textBox7.Text) > 0)
{
som = som + Int32.Parse(textBox7.Text);
aantal++;
}
}
} if (textBox8.TabIndex == t2)
{
if (textBox8.Text != "")
{
if (Int32.Parse(textBox8.Text) > 0)
{
som = som + Int32.Parse(textBox8.Text);
aantal++;
}
}
}
gemiddelde = som / aantal;
textBox10.Text = gemiddelde.ToString();
}
}
private void btnLeegmaken_Click_1(object sender, EventArgs e)
{
foreach (Control ctrl in this.tabPage1.Controls)
{
string typeCtrl = Convert.ToString(ctrl.GetType());
if (typeCtrl == "System.Windows.Forms.TextBox")
{
ctrl.Text = "";
}
}
}
private void stoppen_Click(object sender, EventArgs e)
{
this.Close();
}
}
}