Title: MIC 215
1MIC 215
- Introduction to programming in VB.Net
2Getting started
Select Windows application
Select Visual basic project
Its important to set the path where you will
store your files e.g. your local C drive at home
or h drive at the University
Rename your file so you have a relevant name e.g
game1
3The VB.Net IDE
View-code/designer
Solution name
toolbox
Project name
Form name
4Some Useful Properties
- Visible
- BackColor
- TextAlign
- Font
- Name
- Text
5Naming Objects
- Use the Property window to change the Name
property of an object - Good Programming habit is that each name begins
with three letter prefix that identifies the type
of control.
6Visual Basic Events
- Code is a set of statements that will be executed
when you run a program. - Write Code for each Event.
- Most Events are associated with Objects.
- The code for each event is called an Event
Procedure.
7The steps for creating a VB program
- Create the Interface.
- Set Properties for the objects.
- Write the code that executes when event occur.
8An Event Procedure Walkthrough
- Create the interface.
- Set Properties.
- Double click on the object to open the Code
window. - Click on the Procedure box to find the event
- Write the code for that event.
9 Example of VB.Net and VB6
- Private Sub cmdMessage_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles cmdMessage.Click - Label1.Text " Hello world"
- End Sub
- ---------------------------------------------
- Private Sub cmdMessage_Click( )
- txtBox.Text Hello
- End Sub
-
10Components of Visual BASIC Statements
- Variables
- Keywords (reserved words)
- Constants
11Variables
- A storage location in main memory whose value can
change during program execution. - These storage locations can be referred to by
their names. - Every variable has three properties a Name, a
Value, and a Data Type. - Types of variables Numeric and String
12Numeric Variables
- Used to store Numbers .
- The value is assigned either by the programmer or
by calculation.
13Constant
- Similar to a variable, but can NOT change during
the execution of a program. - Types of Constants
- numeric constants
- string constants
14 Valid Numeric Constants
- Integer Real number
- -2987 -1900.05
- 16 0.0185
- 5 10.56
15String Constants
- A group of alphanumeric data consisting of any
type of symbols.
16Arithmetic Operations Hierarchy of Operations
- Operator operation Basic expression
- Exponentiation A
B - Multiplication A
B - / Division
A / B - Addition
A B - - Subtraction
A - B
17Examples
- Evaluate the following expressions
- x 3 6 - 12 / 3
- x 4 (8 / 4)
- y 12 6 / (3 (10 - 9))
- z 5 4 2
- m 6 / 3 3
18Keywords
- Words that have predefined meaning to Visual
Basic . - Can Not be used as variable names.
- Example Print
- Cls
- If
- While
19Introduction to the Software Lifecycle
20Requirements Analysis and Specification
The first step - Develop a clear understanding
of the clients needs and wishes
- Functional requirements
- Interviews, questionnaires, observation and
studying etc. - Performance requirements
- Interface
- Performance
- Security
Resulting in a Problem specification A list of
all the functional and performance
requirements in straightforward language
21Program development cycle
- Performing a task on the computer the problem
solving process
Processing
Input
Output
22Program planning
- Analyse
- Design
- Choose the interface objects such as text boxes,
command buttons etc) - Code translate the algorithm into a programming
language - Test and debug
- Complete the documentation
23Structured programming
- Meets modern standards of program design
- should have a modular design
- should only use three types of logical
structures - Sequences
- Decisions
- Loops (iteration)
24Software Design
- High Level Design
- Hierarchy charts
- Storyboarding
- Low Level Design
- Pseudo code
25Pseudo code - Exercise
1. Write pseudo code to indicate how to dress for
the weather. Assume the conditions are that it
may or may not be cloudy, and it may or may not
be cold. If it is cloudy, the person should take
an umbrella. If it is cold, the person should
take a coat.
2. Write a pseudo code description of the
activities involved in purchasing a soft drink
from a vending machine.
3. Write pseudo code for a toy-test activity
which tests toys ! If the toy is made of
plastic, it should be stepped on. If it is made
of metal, hit it with a hammer. If it has
stickers on it, try to peel them off. If it is
metal and painted, scratch the paint with a
nail. If it is metal, has wheels, and has
stickers, then submerge it in water for one hour.