generated arrays, each containing 100 numbers.
i am having a problem with this as it is saying expected class delegate enum interface or struct for void has anyone got an idea what is wrong here if so help is great thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
gemma browsePosted Dec 14, 2010, 7:15 AM
CrishPosted Dec 14, 2010, 5:13 AM
You can refer this below code to solve your issue.
Example:
namespace PickLarger
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
class click
{
public static int buttonclick = 0;
}
public int totalClicks()
{
int total=0;
for(total = 0; total <= 100; total++)
{
total++;
MessageBox.Show("" + total);
}
return total;
}
public int getRandomNumberbtn1()
{
// Finds random number between 1 and 100
Random number = new Random();
int randomNumberbtn1 = number.Next(0, 100);
return randomNumberbtn1;
}
public int getRandomNumberbtn2()
{
// Finds random number between 1 and 100
Random number = new Random();
int randomNumberbtn2 = number.Next(0, 100);
return randomNumberbtn2;
}
private void btn1_Click(object sender, EventArgs e)
{
click.buttonclick++;// Counting button clicks
int r1 = getRandomNumberbtn1();
MessageBox.Show("Your chose Button One which equals : " + getRandomNumberbtn1());
int r2 = getRandomNumberbtn2();
MessageBox.Show("Button Two's random Number is : " + getRandomNumberbtn2());
int highNo;
if (r1 > r2)
{
highNo = r1;
MessageBox.Show("You Win : " + highNo);
}
else
{
highNo = r2;
MessageBox.Show("You Lose");
}
MessageBox.Show("You have clicked a button: " + click.buttonclick + " Times");//Displaying button click count
}
private void btn2_Click(object sender, EventArgs e)
{
click.buttonclick++;// Counting button clicks
int r1 = getRandomNumberbtn1();
MessageBox.Show("Button One's random Number is : " + getRandomNumberbtn1());
int r2 = getRandomNumberbtn2();
MessageBox.Show("Your chose Button Two which equals : " + getRandomNumberbtn2());
int highNo;
if (r2 > r1)
{
highNo = r2;
MessageBox.Show("You Win : " + highNo);
}
else
{
highNo = r1;
MessageBox.Show("You Lose");
}
MessageBox.Show("You have clicked a button: " + click.buttonclick + " Times");//Displaying button click count
}
public void close()
{
int i = click.buttonclick;
for (i=0;i>3;i++)
{
Application.Exit(); // trying to close the form after button clicks equal more than 3
}
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
Suthish NairPosted Dec 13, 2010, 11:24 PM
We can only guess about your problem unless you need to provide full description or details about your post.
Santhosh NPosted Dec 13, 2010, 9:30 PM