0% found this document useful (0 votes)
9 views3 pages

Job Name-4

This lab report details two C# Windows Forms applications developed using Visual Studio 2022. The first program identifies the numerical representation of a selected day from a combo box, while the second generates a list of sequential numbers based on user input. Both programs emphasize user input validation and message box interactions, showcasing essential concepts for creating interactive applications in C#.

Uploaded by

imransarker.web
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Job Name-4

This lab report details two C# Windows Forms applications developed using Visual Studio 2022. The first program identifies the numerical representation of a selected day from a combo box, while the second generates a list of sequential numbers based on user input. Both programs emphasize user input validation and message box interactions, showcasing essential concepts for creating interactive applications in C#.

Uploaded by

imransarker.web
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab Report: C# Windows Forms Applications

Course: Programming with C#


Tools Used: Visual Studio 2022
Language: C#

Objective:

This lab exercise demonstrates two C# programs utilizing Windows Forms applications. The first program
determines the numerical representation of a selected day from a combo box, while the second program
generates a list of numbers based on user input.

Program 1: Day Number Finder

Description:

This program takes a selected day from a combo box and displays its corresponding number in the week
using a message box. If no selection is made or an invalid value is entered, the program prompts the user
accordingly.

Code Implementation:
private void button1_Click(object sender, EventArgs e)
{

if (dayListComboBox.SelectedItem == null)
{
MessageBox.Show("Please select a day from the combo box.", "Day Number of
the Week", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}

string day = dayListComboBox.SelectedItem.ToString();

if (day == "SAT")
{
MessageBox.Show("DAY-1", "Day Number of the week", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else if (day == "SUN")
{
MessageBox.Show("DAY-2", "Day Number of the week", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else if (day == "MON")
{
MessageBox.Show("DAY-3", "Day Number of the week", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else if (day == "TUE")
{
MessageBox.Show("DAY-4", "Day Number of the week", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else if (day == "WED")
{
MessageBox.Show("DAY-5", "Day Number of the week", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else if (day == "THU")
{
MessageBox.Show("DAY-6", "Day Number of the week", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else if (day == "FRI")
{
MessageBox.Show("DAY-7", "Day Number of the week", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Please select a valid day from the combo box.", "Day
Number of the Week", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}

Output:

Program 2: Number List Generator

Description:

This program takes a user-entered number from a text box and generates a list of sequential numbers
from 1 to the entered number. The results are displayed in a list box. The program ensures that only
positive integers are accepted.
Code Implementation:
private void Addition_Click(object sender, EventArgs e)
{
int maxItemNumber;
bool parseNum = int.TryParse(numberTextBox.Text, out maxItemNumber);
if (maxItemNumber > 0 && parseNum)
{
for (int i = 1; i <= maxItemNumber; i++)
{
listItemBox.Items.Add(i.ToString());
}

}else if (!parseNum)
{
MessageBox.Show("Please enter number value.", "Message",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show("Please enter positive number.", "Message",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Output:

Conclusion:

Both programs successfully implement Windows Forms features, user input validation, and message box
interactions. The first program demonstrates control selection handling, while the second program
illustrates iterative data population. These concepts are fundamental for building interactive applications
in C# using Visual Studio.

You might also like