Add a new Form i.e.,FormGenerateRangeNumbers to the
Windows Application i.e.,WABasics
Create three labels,two textboxes and twobuttons
& set the following properties to them
label1:
Text
: From
Name
: lblFrom
label2:
Text
: To
Name
: lblTo
label3:
Text
: Generated Numbers Are
Name : lblNumbers
|
textbox1:
Name
: txtFrom
textbox2:
Name
: txtTo
textbox3:
Name : txtNumbers
ReadOnly : True
|
button1:
Name
: btnGenerate
Text
: Generate
|
Design :-
Generate the Event Handler for btnGenerate Click
Event
& write the following code in Source[FormGenerateRangeNumbers.cs]
using System;
using
System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using
System.Drawing;
using System.Linq;
using System.Text;
using
System.Windows.Forms;
namespace WABasics
{
public partial class FormGenerateRangeNumbers : Form
{
public
FormGenerateRangeNumbers()
{
InitializeComponent();
}
private
void btnGenerate_Click(object sender, EventArgs
e)
{
txtNumbers.Clear();
int
Num1 = Convert.ToInt32(Console.ReadLine());
int
Num2 = Convert.ToInt32(Console.ReadLine());
for
(int i = Num1; i <= Num2; i++)
{
txtNumbers.Text =
txtNumbers.Text + i+ " ";
}
txtFrom.Focus();
}
}
}
|
Result :-
No comments:
Post a Comment