Introduction to
Computer Programming
Visual Basic .Net Programming
Using Visual Studio .Net

MELJUN CORTES
Objectives
This module aims:
• To introduce the software development process;
• To know the different programming construc...
Topics
• The software development process
• Different Control Structures in
programming
• Visual Basic .NET examples
• Lab...
The Software Development Process
1. Problem Analysis
2. Setting up an
algorithm
3. Implementing your
algorithm
4. Running,...
Problem!
Mr. De la Cruz needs a program to compute
grades of 50 students. Grade computation is:
40% Average of 3 Exams
+ 4...
1. Problem analysis
1. What are we asked to do?
Compute the final grade, and
determine if student is passing or not
1. Problem analysis
2. What are the given data (inputs) and results
that are to be produced (outputs)?
Input:
Quiz No. 1 (...
1. Problem analysis
3. How do we accomplish our task?
FG = 40%

Q1 + Q2 + Q3
3

+ 30% (FE)
+ 15% (CP)
2. Set-up Algorithm

Algorithm
a list or sequence of steps that solves the
given problem
Note: The steps should be as deta...
2. Set-up Algorithm
Example:
Step 1.
Step 2.
Step 3.
Step 4.
Step 5.
Step 6.
Step 7.

Get Q1, Q2, and Q3 grade
Get FE grad...
Refining the algorithm
Step 6. Determine if student passed or failed

Step 6. Determine if student passed or failed
Step 6...
3. Implementing the algorithm
Basic Questions:
1.
2.
3.
4.

How do you get input and display output?
How do you store info...
Getting input and output
Using console
Imports System
Public Module Hello
Public Sub Main( )
Console.WriteLine("hello, wor...
Screen output
Getting input and output

Demo using GUI
How do we store data?
Answer: Use variables
Declaring variables:
Dim variable As datatype
Rules:
1. Must begin with a char...
Basic data types in VB .NET
Numerical:
Integer
Float

(whole numbers)
(floating point)

Non-numerical:
Boolean
(true or fa...
Sample Declaration
Dim finalGrade As Float
Dim quiz1 As Integer
Dim name As String
Programming Tips…
1.
2.

3.

Use descri...
Branching constructs
The If statement
Syntax 1: If expression Then
statements
End If
Example
For the problem of Mr. dela Cruz, to determine if
a student passed or failed, we use:
If finalGrade >= 70 Then
Con...
Branching constructs
The If statement
Syntax 2: If expression Then
statements
Else
statements
End If
Example
For the problem of Mr. dela Cruz, to determine if
a student passed or failed, we use:
If finalGrade >= 70 Then
Con...
Branching constructs
The If statement
Syntax 3:

If expression Then
statements
ElseIf expression Then
statements
ElseIf ex...
Example
If finalGrade >= 90 Then
Console.WriteLine(“Very Good”)
ElseIf finalGrade >= 80 Then
Console.WriteLine(“Good”)
Els...
Looping constructs
• Allow a group of statements to be
executed more than once
• Looping statements in VB .NET:
– Do
– For...
Looping constructs
The Do statement
Body of the loop is executed either:
1. while a condition remains true; or
2. until th...
Looping constructs
The Do statement
examples
Do While count < 50
' statements
Loop
Do Until count > 50
' statements
Loop

...
Looping constructs
The For statement
•
•

Body of the loop is executed a fixed
number of times
Looping is controlled by a ...
Looping constructs
Syntax of For statement:
For var = expr To expr [ Step expr ]
statements
Next [ variable_list ]
Looping constructs
Example of For
statement:
For i = 1 To 10
Next

For i = 1 To 10
For j = 1 To 10
Next i, j

For i = 1 To...
4. Run, Test, debug
Different bugs or errors encountered:
• Syntactical errors are caused by deviating
from grammatical ru...
5. Documentation
Reasons for doing documentation:
1. Ease of understanding different parts of the
code.
2. Reduces efforts...
.NET Hands On
Exercises
Exercises
•
•
•
•

Lab1: Flash Cards
Lab2: XChange
Lab3: Student Picker
Lab4: Mine Sweeper
Flash Cards
• Objectives
– Design a graphical user interface.
– Modify the properties of the user controls.
– Create and c...
Flash Cards
• Features
– Generates random
algebra problems.
– Checks user input if
correct or incorrect.
– Optional: scori...
Flash Cards
• Creating the GUI
– Drag and drop controls from the toolbox.
– Use the properties window to modify the window...
Flash Cards
• Declaring Variables
Flash Cards
• Creating Functions
Flash Cards
• Generating the problem
Flash Cards
Flash Cards
Flash Cards
• Checking the answer
Flash Cards
• Giving hints
XChange
• Objectives
– Modify the properties of the user controls.
– Create and call functions.
– Convert data types.
– Cr...
XChange
• Features
– Converts one value to
another based on a
given formula.
– Customizable
conversion functions.
XChange
• Synchronize TrackBar and Label
XChange
• Convertion Functions
XChange
• Convert Left Value
XChange
• Convert Right Value
XChange
• Dollar to Peso Conversion
XChange
• Grade Equivalent of 70 pt Exam
XChange
• Other Applications
–
–
–
–

Celsius to Fahrenheit
Pounds to Kilos
Inches to Centimeters
Etc.
Teaching Assistant
• Objectives
– Call functions and pass parameters
– Practice looping constructs and conditions
– Work w...
Teaching Assistant
• Features
– Class attendance
checker
– Random student
selection
– Load/Save class lists
Teaching Assistant
• Adding new students
Teaching Assistant
• Deleting students
Teaching Assistant
• Checking class attendance
Teaching Assistant
• Checking class attendance
Teaching Assistant
• Checking class attendance
Teaching Assistant
• Create a random function
Teaching Assistant
• Randomly select a present student
Upcoming SlideShare
Loading in …5
×

MELJUN CORTES VB.NET Technical faculty module part2 wsd

523 views

Published on

MELJUN CORTES VB.NET Technical faculty module part2 wsd

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
523
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

MELJUN CORTES VB.NET Technical faculty module part2 wsd

  1. 1. Introduction to Computer Programming Visual Basic .Net Programming Using Visual Studio .Net MELJUN CORTES
  2. 2. Objectives This module aims: • To introduce the software development process; • To know the different programming constructs of Visual Basic .NET; and • To enhance the programming skills of the participants.
  3. 3. Topics • The software development process • Different Control Structures in programming • Visual Basic .NET examples • Lab Exercise
  4. 4. The Software Development Process 1. Problem Analysis 2. Setting up an algorithm 3. Implementing your algorithm 4. Running, Testing, & Debugging 5. Documentation
  5. 5. Problem! Mr. De la Cruz needs a program to compute grades of 50 students. Grade computation is: 40% Average of 3 Exams + 40% Final Exam 20% Class participation 100% Once grade of a student is computed the program also displays if student passed or failed. Passing grade is 70%.
  6. 6. 1. Problem analysis 1. What are we asked to do? Compute the final grade, and determine if student is passing or not
  7. 7. 1. Problem analysis 2. What are the given data (inputs) and results that are to be produced (outputs)? Input: Quiz No. 1 (Q1) Output: Quiz No. 2 (Q2) Final Grade (FG) Quiz No. 3 (Q3) Final Exam (FE) Class Participation (CP)
  8. 8. 1. Problem analysis 3. How do we accomplish our task? FG = 40% Q1 + Q2 + Q3 3 + 30% (FE) + 15% (CP)
  9. 9. 2. Set-up Algorithm Algorithm a list or sequence of steps that solves the given problem Note: The steps should be as detailed as possible.
  10. 10. 2. Set-up Algorithm Example: Step 1. Step 2. Step 3. Step 4. Step 5. Step 6. Step 7. Get Q1, Q2, and Q3 grade Get FE grade Get CP grade Calculate the FG using the formula Display the final grade FG Determine if student passed or failed If students processed < 50, go back to step 1 and process next student.
  11. 11. Refining the algorithm Step 6. Determine if student passed or failed Step 6. Determine if student passed or failed Step 6.1. If FG < 70%, display student failed otherwise, display student passed
  12. 12. 3. Implementing the algorithm Basic Questions: 1. 2. 3. 4. How do you get input and display output? How do you store information? How do you write formula? How do you make a program perform statements depending on different situations? 5. How do you make a program repeat parts of itself?
  13. 13. Getting input and output Using console Imports System Public Module Hello Public Sub Main( ) Console.WriteLine("hello, world") End Sub End Module
  14. 14. Screen output
  15. 15. Getting input and output Demo using GUI
  16. 16. How do we store data? Answer: Use variables Declaring variables: Dim variable As datatype Rules: 1. Must begin with a character or underscore 2. Cannot have special characters 3. Cannot be a reserved word
  17. 17. Basic data types in VB .NET Numerical: Integer Float (whole numbers) (floating point) Non-numerical: Boolean (true or false values) Char (a single character) String (many characters)
  18. 18. Sample Declaration Dim finalGrade As Float Dim quiz1 As Integer Dim name As String Programming Tips… 1. 2. 3. Use descriptive variable names Don’t use names that differ by only one character ex. Dim final As Float Dim finals As Float Use names that are not too long and not too short
  19. 19. Branching constructs The If statement Syntax 1: If expression Then statements End If
  20. 20. Example For the problem of Mr. dela Cruz, to determine if a student passed or failed, we use: If finalGrade >= 70 Then Console.WriteLine(“Passed”) End If If finalGrade < 70 Then Console.WriteLine(“Failed”) End If
  21. 21. Branching constructs The If statement Syntax 2: If expression Then statements Else statements End If
  22. 22. Example For the problem of Mr. dela Cruz, to determine if a student passed or failed, we use: If finalGrade >= 70 Then Console.WriteLine(“Passed”) Else Console.WriteLine(“Failed”) End If
  23. 23. Branching constructs The If statement Syntax 3: If expression Then statements ElseIf expression Then statements ElseIf expression Then statements Else statements End If
  24. 24. Example If finalGrade >= 90 Then Console.WriteLine(“Very Good”) ElseIf finalGrade >= 80 Then Console.WriteLine(“Good”) ElseIf finalGrade >= 70 Then Console.WriteLine(“Satisfactory”) Else Console.WriteLine(“Needs Improvement”) End If
  25. 25. Looping constructs • Allow a group of statements to be executed more than once • Looping statements in VB .NET: – Do – For – For Each
  26. 26. Looping constructs The Do statement Body of the loop is executed either: 1. while a condition remains true; or 2. until the condition becomes true
  27. 27. Looping constructs The Do statement examples Do While count < 50 ' statements Loop Do Until count > 50 ' statements Loop Do ' statements Loop While count <= 50 Do ' statements Loop Until count >= 50 Do ' statements Loop
  28. 28. Looping constructs The For statement • • Body of the loop is executed a fixed number of times Looping is controlled by a loop control variable
  29. 29. Looping constructs Syntax of For statement: For var = expr To expr [ Step expr ] statements Next [ variable_list ]
  30. 30. Looping constructs Example of For statement: For i = 1 To 10 Next For i = 1 To 10 For j = 1 To 10 Next i, j For i = 1 To 10 For j = 1 To 10 Next Next
  31. 31. 4. Run, Test, debug Different bugs or errors encountered: • Syntactical errors are caused by deviating from grammatical rules of the language. • Logical errors are caused due to faulty algorithm formulation
  32. 32. 5. Documentation Reasons for doing documentation: 1. Ease of understanding different parts of the code. 2. Reduces efforts during program maintenance and problem reconstruction. Internal Documentation in VB .NET: „ This is a comment
  33. 33. .NET Hands On Exercises
  34. 34. Exercises • • • • Lab1: Flash Cards Lab2: XChange Lab3: Student Picker Lab4: Mine Sweeper
  35. 35. Flash Cards • Objectives – Design a graphical user interface. – Modify the properties of the user controls. – Create and call functions. – Perform input and output operations. – Create and evaluate statements and expressions. – Implement and analyze program branching.
  36. 36. Flash Cards • Features – Generates random algebra problems. – Checks user input if correct or incorrect. – Optional: scoring – Optional: hints
  37. 37. Flash Cards • Creating the GUI – Drag and drop controls from the toolbox. – Use the properties window to modify the windows controls. – Change the names of the controls.
  38. 38. Flash Cards • Declaring Variables
  39. 39. Flash Cards • Creating Functions
  40. 40. Flash Cards • Generating the problem
  41. 41. Flash Cards
  42. 42. Flash Cards
  43. 43. Flash Cards • Checking the answer
  44. 44. Flash Cards • Giving hints
  45. 45. XChange • Objectives – Modify the properties of the user controls. – Create and call functions. – Convert data types. – Create and evaluate statements and expressions. – Handle Windows control events.
  46. 46. XChange • Features – Converts one value to another based on a given formula. – Customizable conversion functions.
  47. 47. XChange • Synchronize TrackBar and Label
  48. 48. XChange • Convertion Functions
  49. 49. XChange • Convert Left Value
  50. 50. XChange • Convert Right Value
  51. 51. XChange • Dollar to Peso Conversion
  52. 52. XChange • Grade Equivalent of 70 pt Exam
  53. 53. XChange • Other Applications – – – – Celsius to Fahrenheit Pounds to Kilos Inches to Centimeters Etc.
  54. 54. Teaching Assistant • Objectives – Call functions and pass parameters – Practice looping constructs and conditions – Work with list controls – Use the features of collections – Handle file input and output
  55. 55. Teaching Assistant • Features – Class attendance checker – Random student selection – Load/Save class lists
  56. 56. Teaching Assistant • Adding new students
  57. 57. Teaching Assistant • Deleting students
  58. 58. Teaching Assistant • Checking class attendance
  59. 59. Teaching Assistant • Checking class attendance
  60. 60. Teaching Assistant • Checking class attendance
  61. 61. Teaching Assistant • Create a random function
  62. 62. Teaching Assistant • Randomly select a present student

×