# random number generator

• ### Question

• so my problem is to create a random number generator and display the number in the text boxes as if they were dice. so 1-6. i created a similar project like this in a console but now i have to use a windows form application. i literally have only gotten as far as the pseudo code...  i know that passing parameters by reference would be easiest but im still kinda new and unsure how to do that..

```private void button1_Click(object sender, EventArgs e)
{
// define variables
// make new random number object
// display random number  in textbox1 and textbox2
// if numbers are 6 and 6, display "Box Cars!" in label1
// if numbers are 1 and 1, dispay "Snake-eyes!" in label1
// string one = " " + nL + " 1 " + nL + " ";
// string two = "1 " + nL + " " + nL  + " 1";
// string three = "l" + nL + " l " + nL + " l";
// string four = "1 1" + nL + " " + nL + "1 1";
// string five = "1 1" + nL + " 1 " + nL + "1 1";
// string six = "1 1" + nL + "1 1" + nL + "1 1";

}```

Lyndsee Elizabeth

Monday, November 17, 2014 1:16 AM

• Random Class

Retrieve integers in a specified range

在現實生活中，你和誰在一起的確很重要，甚至能改變你的成長軌跡，決定你的人生成敗。 和什麼樣的人在一起，就會有什麼樣的人生。 和勤奮的人在一起，你不會懶惰； 和積極的人在一起，你不會消沈； 與智者同行，你會不同凡響； 與高人為伍，你能登上巔峰。

• Marked as answer by Monday, November 24, 2014 10:04 AM
Monday, November 17, 2014 4:47 AM
• To get a random number you can use this:

```Random rnd = new Random();
int dice = rnd.Next(1, 7); // creates a number between 1 and 6```

Then, to put it in a text box you should use the Text property of the textbox:

`yourTextBox.Text = dice.ToString();`

Noam B.

• Proposed as answer by Tuesday, November 18, 2014 6:37 AM
• Marked as answer by Monday, November 24, 2014 10:04 AM
Monday, November 17, 2014 11:21 AM

### All replies

• Random Class

Retrieve integers in a specified range

在現實生活中，你和誰在一起的確很重要，甚至能改變你的成長軌跡，決定你的人生成敗。 和什麼樣的人在一起，就會有什麼樣的人生。 和勤奮的人在一起，你不會懶惰； 和積極的人在一起，你不會消沈； 與智者同行，你會不同凡響； 與高人為伍，你能登上巔峰。

• Marked as answer by Monday, November 24, 2014 10:04 AM
Monday, November 17, 2014 4:47 AM
• To get a random number you can use this:

```Random rnd = new Random();
int dice = rnd.Next(1, 7); // creates a number between 1 and 6```

Then, to put it in a text box you should use the Text property of the textbox:

`yourTextBox.Text = dice.ToString();`

Noam B.