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.