Hey everyone,
I've been stuck on this for a while now and I am not sure on what to do, so help would be great!
I have created an application that displays random images in a
picturebox when a button is clicked. I have done this by creating an
array of images, and using the random class.
I also have a textbox for user input, so that when a random image
appears (flag of america), the user should be able to guess what flag it
is, and type his/her answer into the textbox.
How would I make this comparison? A little guidance would be great:)
My code so far:
public void button1_Click(object sender, EventArgs e)
{
//Array of images
Image[] images = new Image[3];
images[0] = Image.FromFile(@"C:\Users\Momo\Desktop\f… 1\india.png");
images[1] = Image.FromFile(@"C:\Users\Momo\Desktop\f… 1\australia.png");
images[2] = Image.FromFile(@"C:\Users\Momo\Desktop\f… 1\america.png");
int number = (r.Next(0, images.Length));
pictureBox1.Image = images[number];
Thank you very much:)
Loading
Sukesh MarlaPosted Sep 8, 2012, 11:21 AM
Do one thing, Create 2 arrays
Image[] images = new Image[3];
images[0] = Image.FromFile(@"C:\Users\Momo\Desktop\f… 1\india.png");
images[1] = Image.FromFile(@"C:\Users\Momo\Desktop\f… 1\australia.png");
images[2] = Image.FromFile(@"C:\Users\Momo\Desktop\f… 1\america.png");
.
.
string[] strNames=new String[3];
strNames[0]="india";
strNames[1]=" australia ";
.
.
.
int number = (r.Next(0, images.Length));
pictureBox1.Image = images[number];
pictureBox1.Tag= strNames[ number];
No check if Textbox,Text.ToUpper()== pictureBox1.Tag.Tostring().toUpper()
Check this is correct answer if it helped.