0% found this document useful (0 votes)
37 views

Activity 2 Visual Studio (1) CTV

This document provides instructions for creating a simple Windows form application in Visual Studio 2019 that calculates the average of two subject marks. It outlines 11 steps to develop the application, including: 1) Creating a new Windows Forms project, 2) Adding a new form, 3) Designing the form with controls from the toolbox, 4) Naming controls and adding labels, 5) Viewing the form code, 6) Declaring and initializing variables, 7) Writing a validating event to check input, 8) Writing a button click event to calculate and display the average, and 9) Running the application. The goal is to practice using functions, events, and if/else statements in C# to validate input and perform calculations.

Uploaded by

shaheenahmedjh
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)
37 views

Activity 2 Visual Studio (1) CTV

This document provides instructions for creating a simple Windows form application in Visual Studio 2019 that calculates the average of two subject marks. It outlines 11 steps to develop the application, including: 1) Creating a new Windows Forms project, 2) Adding a new form, 3) Designing the form with controls from the toolbox, 4) Naming controls and adding labels, 5) Viewing the form code, 6) Declaring and initializing variables, 7) Writing a validating event to check input, 8) Writing a button click event to calculate and display the average, and 9) Running the application. The goal is to practice using functions, events, and if/else statements in C# to validate input and perform calculations.

Uploaded by

shaheenahmedjh
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/ 18

Degree of Bachelor of Information Technology ITE 1112 – Visual Application Programming

Faculty of Information Technology


University of Moratuwa

Degree of Bachelor of Information Technology (BIT)External

ITE1112: Visual Application Programming – Activity 2

Learning Objectives: Understand fundamentals of validations

Question 1:

Create the simple application to implement an Aggregation Function-Average for the two subject’s
marks. When you submit the marks of the two-subject average should be displayed in given text
box.

Your final output should be as below


Answer

Steps for developing the above application:

1. On the start page of the visual studio 2019, you can create new project as below.
2. In the search box type Windows form App. Then, select Windows form App
3. Config your project as follow
• Name the application as you need. Ex: WinformApp1
Then Project will be created as follow
4. Click on the project and you can Add new forms for the project as follow
Then select new Item

Next Select Form (Windows form)


5. Next you ready to design the on the windows form with Toolbox.

As below you can design your form by dragging tools on the forms form the toolbox:
(Hope now you have some idea how to design windows application with practice in
previous lab sheet.)

6. Create new application and default form design as below with toolbox.

By practicing in previous activity now you know how to design form with tool box.
7. Next you name all control and add display text for buttons and labels and add other
features with property window.

8. After you compete the naming for all controls next right click on the form and select the
view Code.

• Now you can view form.cs. In form.cs you can initiate the variable as below.
• Declare variable and initialize the variable following below coding.
• Use access modifiers as privet (variable cannot access out of the form.cs).
• Do read only for the txtAverage (then textbox cannot edit)
9. Next you need to write event for the validation.

• Select the validating event under the focus menu in the property event.
• Next you can validate the text field as below.
Code for validating event

• Here you can use if statement for the validating.


10. You can write submit button click event as below.

• Right click on the submit button and select the properties


• Next select the event in the property window.
• After that select the click event.
• Next write btnsubmit_click event
Coding for Submit button click event

Here conditions have checked with If statement. Be practice if statement well with this
application.

Steps:

• First you need check validating variables in the if statement.

• Next you need to assign text box value to the related variable in if statement one.
• After that you need to check the result variable in another if statement.

• Same way checks the result further as need in if else and else statement
• finally assign the result you need to display on label according to average mark.
11. Finally run the application

• End of the activity, you have got some ideas about how to develop simple application
with functions, event, if statements with C# with visual studio.

• Please follow the above Steps further and rewrite different event using C# in visual
studio.

You might also like