Hi there folks,
I'm working on a World of Warcraft loot distributor and have the bulk of the code laid out.
The majority of the actual programming is done but now as I go back to clean up the code I see a glaring issue.
The button click event that I'm using is a 1600+ Line if statement...
This is a problem.
I thought that I would solve the issue by using a For loop however because of the amount of information compared in one Button click I can't outright add a For loop.
Here's a bit of sample code.
private void button2_Click(object sender, EventArgs e)
{
if (l1tag > 0)
{
if (l1tag == 1)
{
if (mailarmor.Checked || radioButton1.Checked || platearmor.Checked || onemaces.Checked || oneaxes.Checked || oneswords.Checked || twomaces.Checked || twoswords.Checked || twoaxes.Checked || polearms.Checked)
{
rannum = randNum.Next(101);
textBox1.Text = rannum.ToString();
i++;
}
else
{
textBox1.Text = "Not Eligible for Roll";
i++;
}
}
else if (l1tag == 2)
{
if (clotharmor.Checked || radioButton1.Checked || leatherarmor.Checked || onemaces.Checked || twomaces.Checked || polearms.Checked || staves.Checked || fistweapons.Checked || daggers.Checked)
{
rannum = randNum.Next(101);
textBox1.Text = rannum.ToString();
i++;
}
else
{
textBox1.Text = "Not Eligible for Roll";
i++;
}
}
else if (l1tag == 3)
{
if (mailarmor.Checked || radioButton1.Checked || onemaces.Checked || twomaces.Checked || oneaxes.Checked || twoaxes.Checked || staves.Checked || fistweapons.Checked || daggers.Checked)
{
rannum = randNum.Next(101);
textBox1.Text = rannum.ToString();
i++;
}
elseThe above code continues until l1tag = 10 at which point a blank is drawn. The program then moves to textbox2 and starts to figure out what to include in said textbox...
Unfortunately this means the code is repeated again and again...
TL;DR
What I basically need to do is make it so that as i is incremented, the textbox and variable l1tag also increases in value. (For instance if i = 2 then textBox2.Text and l2tag need to be used)
Are there any simple ways in which I can accomplish this? Thanks in advance! ![]()
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.