Making a methods output into a GUI textbox

Im trying to make a method that loops and output's the numbers into a GUI textbox when i press a button but i cant because the error says the textbox doesn't exist in that context.

int randomNumberGen(int a, int b) { int amountOfNumbers = a; /Min Number/ int numberRange = b; /Max Number/ Random r = new Random(); /creates random object/

 for (int i = 0; i < numberRange; i++) { int randomNum = r.Next(numberRange); //X is a number, will create a number between 0 and X txtBoxRandomNumber.Text = randomNum; } } 

This is my method and im trying to get this to loop and create a random number output every time it loops and then those numbers get displayed in the textbox in my GUI. Please help i am stumped!

by RyceKrispies via /r/csharp

Leave a Reply