Skip to main content

Command Palette

Search for a command to run...

Windows Forms Application – Practice on Conditions, Switch & Loops

Published
2 min read
Windows Forms Application – Practice on Conditions, Switch & Loops
A
I co-founded🫆digizen (fighting internet chaos 🧠), building an AI app to tackle misinformation, and running ideaGeek to turn “I have an idea” into real startups. I also share tech + travel on YouTube (TechNomad & Rz Omar). I touch grass too 🌱… but mostly to debug life 💻

Lab Scenario

You are required to design ONE Windows Form Application that contains separate buttons for practicing:

  1. Conditions (if / else)

  2. Switch statement

  3. Loop structures

Each button should perform a different logical task when clicked.


Form Design Instructions

Create a Windows Form with the following controls:

Form Name: FrmControlStructures

Controls to Add

Control TypeNamePurpose
LabellblTitleDisplay application title
TextBoxtxtInputAccept user input
ButtonbtnConditionCondition task
ButtonbtnSwitchSwitch-case task
ButtonbtnLoopLoop task
LabellblOutputDisplay output

Task 1: Condition (If / Else)

Button: btnCondition

Task Description

  • Ask the user to enter a number

  • Check whether the number is:

    • Positive

    • Negative

    • Zero

Expected Output

Display the result in a MessageBox or Label

Task 2: Switch Statement

Button: btnSwitch

Task Description

  • Enter a number from 1 to 7

  • Display the corresponding day of the week

Expected Output

InputOutput
1Monday
2Tuesday
......
7Sunday

Task 3: Loop Structure

Button: btnLoop

Task Description

  • Enter a number N

  • Display numbers from 1 to N using a loop

Expected Output

Example: Input = 5
Output: 1 2 3 4 5

More from this blog

T

TechNomad

46 posts

TechNomad is mostly coding exercises, not long boring explanations 😌. I share what I teach and learn through hands-on problems—mainly for my students, but anyone can jump in. If you learn by doing (and breaking things), you’ll fit right in. Less theory, more “try this and see what happens.”