I need a bit of help with this code I am writing to produce and test the different types of loop conditions It has several lines that have errors that are causing the compiler to not build the solution. Don't know if it is the specific library that I am not calling right or if I am missing something in particular with the code. I created a particular folder that stores the correct images that I want the loop to use for the textbox but it still has errors where it states there is a missing semicolons:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PictureBox
{
public partial class Form1 : Form
{
int num1, num2;
Image[] Bully= new Image[10];
int randomNum;
Image image = Image.FromFile("BullyBlitzPets");
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int i = 0;
pictureBox1.Image = Bully[i];
i++;
Bully{0} = Image.FromFile("Bully1.jpeg");
Bully{1} = Image.FromFile("Bully2.jpeg");
Bully{2} = Image.FromFile("Bully3.jpeg");
Bully{3} = Image.FromFile("Bully4.jpeg");
Bully{4} = Image.FromFile("Bully5.jpeg");
Bully{5} = Image.FromFile("Bully6.jpeg");
if (int.TryParse(textBox1.Text, out num1))
{
if (int.TryParse(textBox2.Text, out num2))
{
int i = 1;
while ( 1 < num2)
{
MessageBox.Show("i=" + i);
pictureBox1.Image = Bully{i};
i++;
}
}
}
}
private void Form2_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
this.Hide();
}
private void button2_Click(object sender, EventArgs e)
{
Bully{ 0} = Image.FromFile("Bully1.jpeg");
Bully{ 1} = Image.FromFile("Bully2.jpeg");
Bully{ 2} = Image.FromFile("Bully3.jpeg");
Bully{ 3} = Image.FromFile("Bully4.jpeg");
Bully{ 4} = Image.FromFile("Bully5.jpeg");
Bully{ 5} = Image.FromFile("Bully6.jpeg");
if (int.TryParse(textBox2.Text, out num2))
{
for (int i = num1; i <= num2, i++)
{
MessageBox.Show("Bully Number= " + i);
pictureBox1.Image = Bully{i};
}
}
}
private void avg1_Click(object sender, EventArgs e)
{
double res = avg1(1, 100);
textBox4.Text = res.ToString();
double res = avg1(1, 100);
textBox4.Text = res.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
Random random = new Random();
randomNum = random.Next(1, 42);
textBox3.Text = randomNum.ToString();
}
}
}
Aucun commentaire:
Enregistrer un commentaire