week 4
System
Select Statements
A selection statemetn is a type of conditional statement, these allow the the programmers to make a choice/selection about
which lines of code to run. Within VB .NETî a number of selection types are available the commonly used are
ââ¬ËIfââ¬Â¦thenââ¬Â¦elseââ¬â¢ and ââ¬ËSelectââ¬Â¦Caseââ¬â¢.
The ââ¬ËIf...thenââ¬Â¦elseââ¬â¢ statement
Understanding the above code, the first TextBox (TextBox1) will allow the entry of a date in the format dd/mm/yy, e.g.
29/08/81 would be entered for 29 August 2081.
The second TextBox (TextBox2) will allow entry of a time.
If a user were to enter an invalid date (tested using the IsDate function in VB .NETî),
the first part of the ââ¬ËIfââ¬Â¦thenââ¬Â¦.elseââ¬â¢ statement displays a message box and then user is returned to the Date TextBox (TextBox1)
for another try.
There is a test for a valid date when the user moves away from the Date TextBox. This is performed by the ââ¬ËLeaveââ¬â¢ event handler.
But if the user enters a valid date, the ââ¬Ëelseââ¬â¢ part of the ââ¬ËIfââ¬Â¦thenââ¬Â¦elseââ¬â¢ function is ran. This simply pops up a message box,
but displays a confirmation that the date was acceptable.

Selectââ¬Â¦Case statement
Case statements are usualy found in places where code is simplified to enable a program to match a single value (or range of values)
from a list of given possibilities.
Example of the ââ¬ËSelectââ¬Â¦Caseââ¬â¢ statement.

Loops
Loops allow a program to perform a number of actions repeatedly. Unless the loop is infinite, it will have an element or condition statement
that will make it to stop.
Within the VB .NET framework there are a number of different loops that can be used these are,
Forââ¬Â¦Next
The ââ¬ËForââ¬Â¦Nextââ¬â¢ statement is one of the most commonly used tools in almost all programming languages. A loop uses a predefined
number of times that is set by a programmer, that a piece of code is ran until a statement is met, usually controlled by a counter.
The example below shows how an application uses a ââ¬ËForââ¬Â¦Nextââ¬â¢ loop to generate a childââ¬â¢s times table based on two inputs (the table number
itself and the number of rows required).
Doââ¬Â¦loop
The ââ¬ËDoââ¬Â¦Ã¢â¬â¢ loop can either check a condition before- or after the lines of code that are being repeated. The example below a vowel counter uses the Doââ¬Â¦Ã¢â¬â¢ loop. The event handler is triggered when a new keystroke is made. The application then runs a check after the condition ââ¬ËDoââ¬Â¦Ã¢â¬â¢ loop which repeats until the counter is greater than the length of the current text stored in TextBox1. Inside the loop, a ââ¬ËSelectââ¬Â¦Caseââ¬â¢ is used to examine each character (by using the MIDfunction) and increment the appropriate counter when a vowel is matched.
Whileââ¬Â¦End
This works in a similar fashion to the pre-check ââ¬ËDo...ââ¬â¢ loop as shown above, so we wonââ¬â¢t dwell too much on it here!
Using the tutorial sheet above create the code to enable the use of one of the above covered loops
5 min's
How an operating system can be viewed as an event driven application
Event driven programs for non-graphical applications
Where might this happen? Well if we look closer you may find them in a number of places that you might never of considered, things like;
- Alarms
- Traffic light systemes
- Microwaves
- Washing Machines
- DOS (Disk Operating System) aka Command line (CLI)
- TV remote
Other places are discussed in the short video below.
1. Name three different event driven programming languages.
2. Common triggers can be caused by the ______or the ________? Complete this sentence.
3. Name three possible system events.
4. Give three advantages of event driven programming languages.
5. Give three disadvantages of event driven programming languages.
EXTENTION
EXTENTION
STRETCH & CHALLENGE
The information covered in this page covers the knowledge and understanding linked to the criterion in the table below.
Links to Assessment Criteria | Description |
---|---|
LO1 |
Understand the features of event driven programming: Key features: service oriented; time driven; event handlers; trigger functions; events eg mouse, keyboard, HTML object, form, user interface; event loops; flexibility; suitability for graphical interfaces; simplicity of programming; ease of development |
LO2 |
Be able to use the tools and techniques of an event driven language: Triggers: eg key press, alarm, system event, touch screen event, mouse click Tools and techniques: eg use of tool boxes and controls, selection, loops, event handlers, triggers, objects and object properties, menus; debugging tools Variables: declaring variables; scope of variables; constants; data types |
Functional Skills English | Reading, Writing, Comprhension, Problems Solving, Nouns |
Functional Skills Maths | Compression,Reduction |
British Values | None covered in this session. |
Equality and Diversity |
Last Updated
2018-04-16 13:27:00
English and Maths
English
0Maths
Stretch and Challenge
Stretch and Challenge
- Fast to implement
- Accessible by default
- No dependencies
Homework
Homework
Equality and Diversity Calendar
How to's
How 2's Coverage
00
Links to Learning Outcomes |
Links to Assessment criteria |
|
---|---|---|
Files that support this week
Week 3←
PrevWeek 4←
PrevWeek 5←
Prev→
Next