Friday, August 9, 2019

How To Generate a Random Number in c# (visual studio 2017) WinForm Application

How To Generate a Random Number in c# (visual studio 2017) WinForm Application

1.  Double click on the visual studio 2017 to open 

2.  Put the three Three TextBox in the front end 






3.  Put the code in back end

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace RNG
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            timer1.Start();
        }

        private int a = 0;
        private int b = 50;
       
   
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            Random rnd = new Random();
            textBox1.Text = rnd.Next(0, 100).ToString();
            textBox2.Text = a++.ToString();
            textBox3.Text = b++.ToString();
            
        }
    }
}



4.  Set The timer1 Property & Events