i have a program that is supposed to display a certain text in a richtextbox based on what is already in the text box.The word supposed to display the rich text box is wrong but only when the text box displays d1.
private void button5_Click(object sender, EventArgs e)
{
// richTextBox1.Text = "u1";
int i = this.RandomNumber(0, 5);
if (i > 2)
{
richTextBox1.Text = "u1";
}
else
{
richTextBox1.Text = "d1";
}
}
private void button3_Click(object sender, EventArgs e)
{
// richTextBox1.Text = "Wrong";
int i = this.RandomNumber(0, 5);
if (i<2)
{
richTextBox1.Text = "Right";
}
else
{
richTextBox1.Text = "Wrong";
}
}
The only problem is that the computer Doesn’t use the same number
You’re calling RandomNumber for each button click, so it’s going to be different each time. It seems like you want something like: