Thank you very much, SelfTaught!!
I could fix my first problem by setting the function type to public.

Now, my last problem is that I cannot call the else-function at the buttom of the code:
Code
else
{
button1_Click();
}
If the generated number is already in the list, I want the program to automatically repeat the button1_Click() -function
Can anyone identify why this doesn't work?
Code
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;
using System.Collections;
namespace WindowsFormsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public int count = 0;
ArrayList numberList = new ArrayList();
public void button1_Click(object sender, EventArgs e)
{
count++;
Random rnd = new Random();
int num = rnd.Next(1, 6);
if (!numberList.Contains(num))
{
numberList.Add(num);
switch (num)
{
case 1:
this.pictureBox1.Image = WindowsFormsApplication8.Properties.Resources.pic1;
break;
case 2:
this.pictureBox1.Image = WindowsFormsApplication8.Properties.Resources.pic2;
break;
case 3:
this.pictureBox1.Image = WindowsFormsApplication8.Properties.Resources.pic3;
break;
case 4:
this.pictureBox1.Image = WindowsFormsApplication8.Properties.Resources.pic4;
break;
case 5:
this.pictureBox1.Image = WindowsFormsApplication8.Properties.Resources.pic5;
break;
}
if (count == 5)
MessageBox.Show("Hurra!");
}
else // this is the part that doesn't work
{
button1_Click();
}
}
}
}
Thanks a lot!
This post was edited by DBK-Leader on Jun 14 2014 01:39am