BitingNermal581581

Hi, im working on using a random number generator to output a number to a text box but i cant get to the final output. Any ideas Heres the code

private void button1_Click(object sender, EventArgs e)

{

Random generator = new Random();

int randomValue;

randomValue = generator.Next(10, 100);

int x = randomValue;

if (int.TryParse("stringValueHere", out x)) ;

{

}

textBox1.Text = (x.ToString());

}



Re: Visual C# Express Edition Random number to string for textbox

jrboddie

You don't need the if(int.TryParse...) statement.

Try this:

Code Snippet

private void button1_Click(object sender, EventArgs e)

{

Random generator = new Random();

int randomValue;

randomValue = generator.Next(10, 100);

int x = randomValue;

textBox1.Text = (x.ToString());

}





Re: Visual C# Express Edition Random number to string for textbox

BitingNermal

Works like a dream, thanks.