Question

In C# Create a windows application which accepts the month number and displays the month name in a label. show the steps...

In C# Create a windows application which accepts the month number and displays the month name in a label. show the steps to follow in visual studio.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new Windows Forms Application in C# is created using Visual Studio 2017 with name "MonthsApplication".This application contains a form with name "Form1.cs".Below are the files associated with form1.

1.Form1.cs[Design]

X Months Application Enter Month Number: Display Month Name

2.Form1.Designer.cs

namespace MonthsApplication
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtMonthNumber = new System.Windows.Forms.TextBox();
this.btnMonthName = new System.Windows.Forms.Button();
this.lblMonthName = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtMonthNumber);
this.groupBox1.Location = new System.Drawing.Point(24, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(249, 86);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Enter Month Number :";
//
// txtMonthNumber
//
this.txtMonthNumber.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtMonthNumber.Location = new System.Drawing.Point(21, 31);
this.txtMonthNumber.Multiline = true;
this.txtMonthNumber.Name = "txtMonthNumber";
this.txtMonthNumber.Size = new System.Drawing.Size(207, 29);
this.txtMonthNumber.TabIndex = 0;
//
// btnMonthName
//
this.btnMonthName.Location = new System.Drawing.Point(75, 116);
this.btnMonthName.Name = "btnMonthName";
this.btnMonthName.Size = new System.Drawing.Size(117, 29);
this.btnMonthName.TabIndex = 1;
this.btnMonthName.Text = "&Display Month Name";
this.btnMonthName.UseVisualStyleBackColor = true;
this.btnMonthName.Click += new System.EventHandler(this.btnMonthName_Click);
//
// lblMonthName
//
this.lblMonthName.Font = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMonthName.Location = new System.Drawing.Point(12, 162);
this.lblMonthName.Name = "lblMonthName";
this.lblMonthName.Size = new System.Drawing.Size(261, 54);
this.lblMonthName.TabIndex = 2;
this.lblMonthName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(285, 225);
this.Controls.Add(this.btnMonthName);
this.Controls.Add(this.lblMonthName);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Months Application";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox txtMonthNumber;
private System.Windows.Forms.Button btnMonthName;
private System.Windows.Forms.Label lblMonthName;
}
}

3.Form1.cs

//namespace
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//application namespace
namespace MonthsApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Month name button
private void btnMonthName_Click(object sender, EventArgs e)
{
//taking month number entered by user
int monthNumber;
if(int.TryParse(txtMonthNumber.Text,out monthNumber))
{
//display month name on the label
lblMonthName.Text= CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(monthNumber);
}
else
{
//display invalid message
lblMonthName.Text = "Enter valid number from 1 to 12";
  
}

}
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :

X Months Application Enter Month Number: Display Month Name

Screen 2:Screen when invalid number is entered

Months Application Enter Month Number: asdf Display Month Name Enter valid number X

Screen 3:Screen showing month name

Months Application Enter Month Number: 6 Display Month Name June X

Screen 4:Screen showing month name

int month umsc Months Application Enter Month Number e C 11 Display Month Name November X

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
In C# Create a windows application which accepts the month number and displays the month name in a label. show the steps...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C# Windows Form program that asks the user to enter a name (in a TextBox) and displays the following message (in...

    Write a C# Windows Form program that asks the user to enter a name (in a TextBox) and displays the following message (in a Label): Hello, yourName! https://youtu.be/6nNiMeWK37w can be helpful... (unfortunately the sound did not record) You will use Visual studio to complete this task. The final deliverable to be uploaded to the assignment dropbox is the entire visual studio solution folder that has been compressed or zipped.

  • Written in C# visual studio (Please show step by step) Create an application that can be...

    Written in C# visual studio (Please show step by step) Create an application that can be used to allow users to enter information such as their names, e-mail addresses, and phone numbers. The application should provide a minimum of four features. The first retrieves and displays the information entered by the user. Output should be displayed in a Windows dialog message box. The second feature clears the entries so that new values can be entered. Provide an “About” feature under...

  • **This program is to be created using Visual Studio C#**Create as a Windows Form application** 1....

    **This program is to be created using Visual Studio C#**Create as a Windows Form application** 1. Output a header in the console: “This is a replacement program” 1. Output a header that states: “This is Program 5” 2. Output a thank you message: “Thank you for running the program.”

  • PLEASE USE VISUAL BASIC* BY VISUAL STUDIO. Visual Basic INTERMEDIATE Create a Windows Forms application. Use...

    PLEASE USE VISUAL BASIC* BY VISUAL STUDIO. Visual Basic INTERMEDIATE Create a Windows Forms application. Use the following names for the project and solution, respectively: Chopkins Project and Chopkins Solution. Save the application in the VB2017\Chap03 folder. Change the form file's name to Main Form.vb. Change the form's name to frmMain. Create the interface shown in Figure 3-37. The interface contains six labels, three text boxes, and two buttons. The application calculates and displays the total number of packs ordered...

  • Please note: This is in Visual Basic. Create an application (windows forms app). Add a label...

    Please note: This is in Visual Basic. Create an application (windows forms app). Add a label and a button to the form. The button’s Click event procedure should declare and initialize a one-dimensional Double array. Use any six numbers to initialize the array. The procedure should display (in the label) the lowest value stored in the array. Code the procedure using the For...Next statement.

  • Q1. Create a Windows Form or MFC Dialog-based application that reads and displays an image, and...

    Q1. Create a Windows Form or MFC Dialog-based application that reads and displays an image, and then uses a slider to resize it from 0 to 100% size (zoom out but at different levels)

  • INSTRUCTIONS #6. Your science teacher has asked you to create an application that displays how much...

    INSTRUCTIONS #6. Your science teacher has asked you to create an application that displays how much a person would weigh on the following planets: Venus, Mars, and Jupiter. The application's interface should allow the user to enter the person's weight on Earth. Perform the steps involved in creating an OO application. (See the Note at the beginning of the Exercises section.) Include a button for clearing the screen. . Create an application, using the following names for the solution and...

  • I need a code summary for these problems Sale Total Create a Visual C# Windows Console...

    I need a code summary for these problems Sale Total Create a Visual C# Windows Console Application that will prompt the user to enter what type of item they are purchasing, the quantity of the item, and the price for the item. Calculate the subtotal, the sales tax and the sales total (subtotal + sales tax) and output all 3 to the user. Assume that the sales tax for your application is 8.5% (create a constant to store this value...

  • write pseudocode for a python application that accepts 10 numbers and displays the second lowest number.

    write pseudocode for a python application that accepts 10 numbers and displays the second lowest number.

  • For C# Scenario: Create a Windows Forms application that accepts the total cost of a sale...

    For C# Scenario: Create a Windows Forms application that accepts the total cost of a sale and the amount submitted by the customer. Calculate and display the correct change from largest denomination to smallest. If the cost exceeds the amount submitted, post a message to the user that they have entered an invalid amount. The program should accept both the cost and the amount submitted into textbox controls. The program should use Try/Catch statements to keep the program from crashing....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT