Previous..
Next..
Here i will explain how to Random Number Generator within range in window application.
Step(1) : Form
Drag and down a 3 lable and 3 TextBox and a button.
Here 3 textboxes in 1st text box we will put minimum value and 2nd textbox we will put maximum value and when we will click on button it will generate a random number and it will we show in 3rd textbox.
Step(2) : Code
Double click on button and write this code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text;
using System.IO;
using System.IO;
namespace First_Csharp_app
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Choose_Btn_click(object sender, EventArgs e)
{
Random rnd = new Random ();
textBox3.Text = rnd.Next( Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text) ).ToString;
//you can also write here
//textBox3.Text = rnd.Next ( 3,500);
}
Now run your application and enter minimum and maximum number and then generate the number.
Previous..
Next..