1.Follow the steps to create a New Project: File-> New Project->C#->Windows Application. And you can change the name of your Application .
2.Now the form has been created with the name Form 1 .And our aim is to produce a Welcome Application.
3.ToolBox tab will be on the Left side .Otherwise get it from View->ToolBox.Then for this Application we need a Label
so by just dragging the Label from the Toolbox we obtain the Label in the Form1.Then the Properties Window can be obtained by View-> Properties Window.In the Properties Windows we have to change the Name of the Label as Labdisp(Label Display).Its for User Convention we use these type of Naming Conventions.4. Then Double Click on the top of the Form .You will get one Code window in which we have to write the Code required for this Program .
5.Now A Function with the name FORM_LOAD is obtained .It is the Event which is executed when the form is Loading ..Write the Following Code in that Function..
private void Form1_Load(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
if (dt.Hour < text = "GOOD MORNING.......">= 12 && dt.Hour <= 15) { labdisp.Text = "GOOD AFTERNOON..........."; } else if (dt.Hour >= 16 && dt.Hour <= 20) { labdisp.Text = "GOOD EVENING........."; } else if(dt.Hour>=21)
{
labdisp.Text = "GOOD NIGHT.............";
}
}
In the Above Code , DateTime denotes the Class
and we are Creating the Object of that Class .And now this Object contains the info about the Date and Time of the System.
6.Then dt.Hour will contain the Hours of our System.And it can be Classified as:
1)if (hour <>12 && Hour <15)>15 && Hour <20)>20) ---------------------GOOD NIGHT .
And this is the BAsic Function of this Program and You can add Butons ,TextBox and many other Controls to this Form. Press F5 for Execution....

No comments:
Post a Comment