Week 1 T&L Activities:

Unit 14 Event Driven Programming

This unit aims to enable learners to develop the skills and understanding required to design and develop event driven applications.

Event driven programming is a very flexible way of allowing programs to respond to many inputs or events. Unlike traditional programming, where the control flow is determined by the program structure, the control flow of event driven programs is largely driven by external events. Typically, event loops are pre-programmed to continually look for information to process. This unit allows learners to become familiar with the underpinning concepts of event driven programming and subsequently to develop particular skills in an event driven language. The unit starts by looking at the features of event driven programming, explores the tools and techniques used in their development and takes learners through design and program development. Learners will use a structured approach to the design and development of applications, ensuring the solution is well documented and tested thoroughly against the original user requirement. Event handling features in many languages including Visual Basic, Visual Basic for Applications and many other systems.


Learning outcomes

On completion of this unit a learner should:

  1. Understand the features of event driven programming
  2. Be able to use the tools and techniques of an event driven language
  3. Be able to design event driven applications
  4. Be able to implement event driven applications.

Key features

Service orientated: - is a term used to describe the concept of multiple services (processes written in different programming languages) advertised and accessed as and when needed by an organisation.

Service oriented is a programming paradigm that is used to write programs that are made for services. If something is requested, the action is carried out, if a user wanted to minimize an application that they are using, they would click on the – icon in the top right of the page and the application will minimize into the task bar, this is service orientated.

Time driven: - is the term used to describe processing which occurs when tasks are regulated by a clock, i.e. actions are occurring at set intervals and typically need a real-time response. In this case, an event could be generated by a ‘timer’ trigger.

Such as cooking a meal with a microwave or can be carried out at certain increments repeatedly such as with traffic lights that change automatically after a certain amount of time.

In addition there are a number of other terms which are used when discussing event driven programming.

Time driven programming is often used in real time, where code execution is controlled by the computer clock. A program is divided into a set of tasks that need to be regularly activated. The activation pattern us stored into a dispatch table, where rules are used to schedule the tasks.

Event handlers: - are the actual program code modules which are executed when a particular trigger has occurred. For example, if a user clicked a button this would trigger an event handler for the code actions associated with the button.

VB.Net uses subroutines for event handling, with the name of the object followed by the name of the event – see below:

Event Handler Image

Trigger functions: - are used by event loops to identify and launch a response to an event which has happened in an event loop. This is what decides what causes the event to take place, for example making the button single click will cause it to run when it is clicked, setting it to double click will make it require 2 clicks for it to run. Every object has a range of trigger functions that can be used to run the event, upwards of 50 or more on some. These are used along with the object’s name to determine with event handler to run Every object has a range of trigger functions, one for each possible event that can happen to it. For example, txtText could have an event handler for the following triggers: GotFocus, TextChanged etc... Temporal triggers mean triggers set off by duration of time State triggers are when the current situation causes a certain set of procedures to run

What is the trigger here??
Event Trigger Image
5 min's

The programmer chooses which event(s) to respond to by selecting the appropriate trigger function. Different controls have different events (events for a text box not the same for a button)

Events (eg mouse, keyboard, HTML object, form, user interface) : - A form is a visual container used to group together user interface components such as text boxes, buttons, labels, checkboxes etc. It is used to provide an input mechanism for a user that is both approachable and functional. For the events within a program to happen, they need to be triggered, this is when the user interacts with an object, which may be a button getting clicked by a mouse, events can be triggered in many different ways, it can be with your mouse, due to movement, left clicking, right clicking or scrolling, the keyboard can also be used to set off events, this can be from pressing certain keys, holding down certain keys or from something being typed into the keyboard. The events happen due to code being assigned to something, for example code might be assigned to a button, so when that button is clicked the code is executed. For example when playing a game with a controller pressing the trigger will cause the gun to fire while moving the stick will cause the character to move. The same trigger can do different events depending on the situation, for example clicking on an icon will do something different to clicking on a button. Every object has a range of trigger functions – one for each possible event A Button has a Click event, a GotFocus event, a MouseHover event etc

Event Trigger Image


Pre-defined functions: - A pre-defined function is a function that is built into the programming language, for example system.out.println is used in java, this is a pre-defined function,

sName=’Zakk’; System.out.println(“Your name is:” +sName);

You can use this as procedural so this code will run as soon as the program is started, or you can assign the code to a button, so that it can triggered through an event. Local variables: - A local variable is a variable that is declared within a method, that variable will only be used by the method where it is mentioned, other methods will not use it. An example of a local variable in the code below is age,

public class Main { public void Age() { int age = 0; age = age + 18; System.out.println(“Your age is: ” +age); } public static void main (String args[]) { main m = new Main(); m.Age(); } }


Event loops: - are processing cycles which continually look for events to happen (e.g. a button click, file deletion or arrival of a data packet over a network). An example of this is when the screen goes to sleep but moving the mouse will get it back again, this is because the event loops are checking for events like this and are running all the time in the background. Event Driven Programs have event loops built into the environment. The loops keep testing the interface to detect whether anything has happened, such as clicking on a button or typing into a textbox etc.
Event Loops are also known as event listeners
Programmers not normally aware of these

The Event loop keeps testing the user interface to see if anything has happened (e.g. clicking on a button or pressing a key) When detected, the event is passed to the trigger function which then finds the appropriate event handler to run the code written for this purpose Other (non user) activities can also cause an event to trigger – typically used in networking and when reading from or writing to files


Flexibility: -
This is what allows the program to have massive variability and enable it to be different to everybody else’s, there is lots of options for the design so it can be whatever the programmer envisioned it to be. They can also decide how they want to write the code and make it work the way the want it to. Programmers have enormous control over where to place code and how to start it. Every object has a good choice of events that a program can respond to. These events give an excellent level of control over exactly what the program will respond to when the user does something

Service Oriented
A lot of networked applications use service oriented techniques so that different applications can reuse code components. Service oriented applications separate the service implementation from the program interface that uses the service. An example is a request from a database.
XML (Extensible Markup Language) is commonly used for interfacing with such service oriented architectures


Suitability for graphical interfaces: -
Event driven programs are very suitable for graphical user interfaces (GUIs) as they are an excellent match for each other. A GUI presents the user with a wide variety of graphical choices and menus that can be used with the mouse or keyboard (or other input devices), usually with no set sequence that the user must follow.

An event driven programming language will use this GUI approach to give the user a variety of controls. Each control reacts to events with code that is just right for each event and for how the program is expected to be used.

Most controls are quite independent from each other, so the code will be modularised into event handlers.



Event driven programming for simplicity of programming and ease of development:

Event driven programming can be a lot easier and simple to use and to program as it is very visual, when creating things such as buttons you can simply just select it, place it onto a form and then just add code to the button so it has some use to the program, this makes it easier to use and more simple as you don’t need to write the code to create things like buttons, you just need to add code to them, this can also save a lot of time, makes programming simple and can make the development process easier. Pre-written code can also be used, you can also select commands from drop down lists, which shows commands that can be used, and this makes developing a program faster, simple and easier.

Event-driven languages such as C#, VB.NET and Visual C++ allow a programmer to build up their program gradually with simple building blocks.

Event Programmers can add and code one object at a time, using simple constructs
Pre-written code and drop-down lists showing choice of possible commands
Errors are highlighted and step through debugging
Code modules can be re-used or imported from libraries, built-in wizards can be used
Online and local help files are readily available


Disadvantages

Errors can be more difficult to spot than with simpler, procedural programs
Programs with complex GUIs may be slower to load and run than simpler programs – particularly if RAM is insufficient
Programs with too many forms can be very confusing and/or frustrating for the user


Using the Activity Sheet, create a simple Calculator, you should ensure that you pay close attention to the table provided in the instructions as this will provide you with the naming conventions that should be used when creating a program in VB.Net.
EXTENTION
Using your now created calculator create buttons for the missing aritmatic operators.Using
EXTENTION
Now you have a simple calculator lets try and make it scientific
STRETCH & CHALLENGE
Now lets try an reproduce the calculator that is available in windows


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 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
Functional Skills English Reading, Writing, Comprhension, Problems Solving, Nouns
Functional Skills Maths Compression,Reduction
British Values None covered in this session.
Equality and Diversity

Files that support this week

English: 0
0
Assessment: 0

0
Learning Outcomes:
Awarding Organisation Criteria:
Maths:
Stretch and Challenge:
E&D / BV
Homework / Extension:
ILT
  →  →  →  →  →  →
Week 2 T&L Activities:

Environment NewLine

Lets look over a function that will enable the inclusion of additional lines

Environment.NewLine The use of the the Environment.NewLine option in VB.Net enables programmers to seperate content over a new line in an object. Say for example you have a button that when a user triggers it the event inputs a sentance or stucture of words in to an object (say a Rich Text Box). The text is reqiured to be shown over a number of lines in the object you would use the Environment.NewLine feature to enable this.
It is worth remembering that if you wish to make this happen with other elements within the code line, i.e. some text, you will need to add the + sign, as in the example below. rtbHTML.Text.Insert(cursorposition, "<p>" + Environment.NewLine + Environment.NewLine + "</p>")

Selection Start

The selection start control indicates the insertion point, or caret, for new text. If you set this property to a location beyond the length of the text in the control, the selection start position will be placed after the last character. This control may be useful when considering the inclusion of information to a text area or rich text box. In the example below you can see that the value that is gathered from this control is stored in a variable so that if the program appends any information it can be called and input at this point.

Dim cursorposition As Integer = rtbHTML.SelectionStart

Using the Activity Sheet, create a webpage editor, you should ensure that you pay close attention to the table provided in the instructions as this will provide you with the naming conventions that should be used when creating a program in VB.Net.
EXTENTION
Now that you have created the editor, create a button the inputs the simple HTML structure in to the Rich Text Box.
STRETCH & CHALLENGE
Now that you have this interactivity enabled in to your editor, try and enable the use to input tags at the point of where the cursor is in the Rich Text Box

Upgraded Editor


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

Files that support this week

English: 0
0
Assessment: 0

0
Learning Outcomes:
Awarding Organisation Criteria:
Maths:
Stretch and Challenge:
E&D / BV
Homework / Extension:
ILT
  →  →  →  →  →  →
Week 3 T&L Activities:

System Information

System information can be useful to programs and programmers, this can enable them to check that a program will run or that the user will need to upgrade or downgrade system setting.
Other users that may find these sorts of features useful in a program are IT professionals, this information could provide them information that could assist in the diagnosis of fault, or the information to the installed software at the present time.


Visual Basic .NET (VB.NET) is a multi-paradigm programming language, implemented on the .NET Framework. Microsoft launched VB.NET in 2002 as the successor to its original Visual Basic language. Although the ".NET" portion was dropped in 2005, this article uses "Visual Basic [.NET]" to refer to all Visual Basic languages releases since 2002, in order to distinguish between them and the classic Visual Basic.
Wikipedia - https://en.wikipedia.org/wiki/Visual_Basic_.NET

The "My" Function

The My feature provides easy and intuitive access to a number of .NET Framework classes, enabling the Visual Basic user to interact with the computer, application, settings, resources, and so on.
Examples

Word Scramble time!!


my.computer.name

The use of the my.computer.name string will provide the user information relating to the computer name. Other features that are available in the my.computer area, are,
My.Computer.Audio Object
My.Computer.Clipboard Object
My.Computer.Clock Object
My.Computer.FileSystem Object
My.Computer.FileSystem.SpecialDirectories Object
My.Computer.Info Object
My.Computer.Keyboard Object
My.Computer.Mouse Object
My.Computer.Network Object
My.Computer.Ports Object
My.Computer.Registry Object

Each of these have further features and functions providing the user with a number of elements of information and tools.

#


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.
#
5 min's

#

#


As you will see in the activity sheet in the resources area you are to create a system information checker. Using this document create the form as per the image presented and using the table to assist you in the naming and property settings. The program is a system checker that is designed to allow IT technician and IT professionals to understand more about the system that they are working on.
An example of such a program that will do this is " Jellybeans "
EXTENTION
Now that you have a working program that presents the information to the user about the system, you have been asked to source and create the code that will enable the program to now present a list of the installed software on the system and to count the number of items that are in the list.
STRETCH & CHALLENGE
Once the List has been created try to find the information to the serial/product keys to the installed software.


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

Files that support this week

English: 0
0
Assessment: 0

0
Learning Outcomes:
Awarding Organisation Criteria:
Maths:
Stretch and Challenge:
E&D / BV
Homework / Extension:
ILT
  →  →  →  →  →  →
Week 4 T&L Activities:

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

Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As System. EventArgs) Handles TextBox1.Leave If Not IsDate(TextBox1.Text) Then MsgBox("Please enter date (dd/mm/yy)", MsgBoxStyle.Information) TextBox1.Focus() Else MsgBox("Date acceptable", MsgBoxStyle.Information) End If End Sub
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

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.

Select Case (Val(TextBox1.Text)) Case 1 MsgBox("Sorry, no discount!", MsgBoxStyle.Information) Case 2 To 5 MsgBox("10% discount.", MsgBoxStyle.Information) Case 6, 7, 8 MsgBox("20% discount.", MsgBoxStyle.Exclamation) Case Else MsgBox("Sorry, you can’t order more than 8.", MsgBoxStyle.Critical) TextBox1.Focus() End Select

loop

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).

Dim counter As Byte Dim newline As String TextBox3.Text = TextBox1.Text &amp; " times table" &amp; vbCrLf For counter = 0 To Val(TextBox2.Text) newline = counter &amp; " X " &amp; TextBox1.Text &amp; " = " &amp; _ Val(TextBox1.Text) * counter &amp; vbCrLf TextBox3.AppendText(newline) Next counter

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. Dim counter As Byte Dim nextchar As Char Dim acount As Byte Dim ecount As Byte Dim icount As Byte Dim ocount As Byte Dim ucount As Byte counter = 1 Do nextchar = Mid(TextBox1.Text, counter, 1) Select Case (nextchar) Case "a", "A" acount = acount + 1 TextBox2.Text = acount Case "e", "E" ecount = ecount + 1 TextBox3.Text = ecount Case "i", "I" icount = icount + 1 TextBox4.Text = icount Case "o", "O" ocount = ocount + 1 TextBox5.Text = ocount Case "u", "U" ucount = ucount + 1 TextBox6.Text = ucount End Select counter = counter + 1 Loop Until counter > TextBox1.TextLength

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! counter = 0 While counter < 10 counter = counter + 1 MsgBox("Loop has run " & counter & " time(s)!") End While

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;

  1. Alarms
  2. Traffic light systemes
  3. Microwaves
  4. Washing Machines
  5. DOS (Disk Operating System) aka Command line (CLI)
  6. 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

Files that support this week

English: 0
0
Assessment: 0

0
Learning Outcomes:
Awarding Organisation Criteria:
Maths:
Stretch and Challenge:
E&D / BV
Homework / Extension:
ILT
  →  →  →  →  →  →
Week 5 T&L Activities:

How to enable a user to print from your Program

I this section we will be reviewing the steps that you need to follow to enable a user to print from your application.

Step 1.
Within the VB.Net application you will need to select the print form option from the printing menu in the visual basic PowerPacks and drag this on to your program window.



Once the feature is added to the bottom bar of the form designer, click on the icon and review the properties window as per the image below



Select the option in print action and set it to "PrinttoPreview"


Clearing a programs text box fileds

In some instances we may need to reset all information that is contained within a programs text boxes, this may occure when a user changes their mind, or when a new user is creating an order. The Code that we use in this instance is.

Dim txt As Control For Each txt In Controls If TypeOf txt Is TextBox Then txt.Text = "" End If Next
#

How to close an application

It may be required at some point in a program to either end the program completely of to close a subwindow of the program that has been opened to provide possible further information, simular to that of a help window. If we needed to close these windows/programs we would need to use the following code.

Close()



5 min's


Checkbox's

The use of checkboxes are usful functions in a program as they have the ability to be set with a defined value that once selected becomes a factor in a possible calculation. This would be useful in area like resturant where an option to go large can be set to add £1.00 more to the cost of a meal. Or in a clothing shop to include a carry bag or to have it gift wrapped as the code below demonstrates.

If GiftWrap.Checked Then dgiftprice = dindgiftwrap * dqty GiftWrapBox.Text = Str(dgiftprice) GiftWrapBox.Text = Format(GiftWrapBox.Text, "Currency") Else dgiftprice = 0.0 GiftWrapBox.Text = Format("0.0", "Currency") End If dtotalprice = dteeprice + dgiftprice TotalPriceBox.Text = Str(dtotalprice) TotalPriceBox.Text = Format(TotalPriceBox.Text, "Currency")


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

Files that support this week

English: 0
0
Assessment: 0

0
Learning Outcomes:
Awarding Organisation Criteria:
Maths:
Stretch and Challenge:
E&D / BV
Homework / Extension:
ILT
  →  →  →  →  →  →
Week 6 T&L Activities:

Radio Buttons

Radio buttons are a commonly used feature in most program and websites, these enable the users to make a selection from a possible number of selections, however it is limited to only enabling them to have one choice at a time, so for example the option of a drink for a person in a fastfood resturant would be,

  • Coke
  • Diet Coke
  • Fanta
  • Water

The option of one of this is required as the person is not likely going to want a mixture of all these drinks. A more common and obvious demonstration of this would be Male or Female and Smoker or non smoker.

The example below describes an option of an item of clothing that is of medium price being selected, this triggers a number of things to happen, the first is that the number that the user has input in to the quantity text box (Qtychosen) is assigned to a variable dqty on line ①
The next line then assigns the result of the value set in dmediumprice and multiplys this by the value in dqty and then adds the value set in the variable dpostpack on line ②
The next line then takes the value that is now stored in the dteeprice variable and converts it to a string using Str and outputs this in to the textbox TeePriceBox by using the .text function at the end of the objects name on line ③.
The next line then takes the value now placed in the textbox and changes the format to a currency on line ④
The next line takes the value stored in the variable dteeprice and adds the assigned value of dgiftprice and assigns it to the variable of dtotalprice ⑤
The value now stored in dtotalprice is then made in to a string on line ⑥ and then attached to the TotalPriceBox text box by using .text
Finaly on line ⑦ the value of the textbox TotalPriceBox is formated to a currency

1. dqty = Val(Qtychosen.Text) 2. dteeprice = dmediumprice * dqty + dpostpack 3. TeePriceBox.Text = Str(dteeprice) 4. TeePriceBox.Text = Format(TeePriceBox.Text, "currency") 5. dtotalprice = dteeprice + dgiftprice 6. TotalPriceBox.Text = Str(dtotalprice) 7. TotalPriceBox.Text = Format(TotalPriceBox.Text, "currency")

This instance of a radio button could be simply copied and reused by a user if there were other options within the radio button selection, just as long as the links to the global variables and changed to link to the correct options.

System


Global Variable Declarations

The use of global declarations are key in programming as this will enable modules of seperate code to refer to them without knowing that others also link to them. These are usually found in the uppermost part of the coding area. This could be useful when creating programs like calculators where the value for Pi (π) could be declaired globally so that other operators can access it.

Const dsmallprice As Decimal = 7.5
#

What is the #
#
5 min's

Uploading an image and having a preview

In some programs users are enabled with the ability to add a file to a system, this could be to upload a document relating to a specific user in a database or it could be to enable the user to customise a design for a product like a tee-shirt where a they can add there own images.
The feature will require a number of different tools from our tool box.

picturebox
Step 1: You will need to drag a picture box on to your form design.
choose
Step 2: You will need to drag a button on to the form to enable the user to select the image from thier computer.
choose
Step 3: You will need to drag a textbox on to the form to enable the user to select the image from thier computer.
Step 4: The code! Below we have an example of the code that is used to link the two features together so that we can get our image and to display it to the user.

Explaining the code


1. The event trigger, "Click"
2. Blank
3. The builtin open dialog box is called, the filter on the open file is set to images as a default
4. Display the open file dialog box
5. Assign the value of the file name selected to the textbox "imagename" using the .text function
6. On this line the system function calls the drawing.image.fromfile function where the value is set to the value contained within the "Imagename" text box and attaches it to the Teedesign imagebox as .image

1. Private Sub ChooseButton_Click(sender As System.Object, e As System.EventArgs) Handles ChooseButton.Click 2. 3. OpenFileDialog1.Filter = "Image Files (*.BMP;*JPG)|*.BMP;*.JPG" 4. OpenFileDialog1.ShowDialog() 5. Imagename.Text = OpenFileDialog1.FileName 6. Teedesign.Image = System.Drawing.Image.FromFile(Imagename.Text) 7. 8. ToolTip1.SetToolTip(Imagename, Imagename.Text) 9. End Sub




EXTENTION
Using the graphic editor of your choice create 5 tee shirt images that use the following a there most dominant colour
1. Red
2. White
3. Green
4. Blue
5. Black

EXTENTION
Make your images professional by adding additional detail to them
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

Files that support this week

English: 0
0
Assessment: 0

0
Learning Outcomes:
Awarding Organisation Criteria:
Maths:
Stretch and Challenge:
E&D / BV
Homework / Extension:
ILT
  →  →  →  →  →  →
Week 7 T&L Activities:

Drop Downs and updates

Some times we will want to enable our users to select an option from a drop down box, this could be for something like a size of a drink or the colour of clothing garment.

' Code to select an image file and load it on to the form TeeImage.Image = System.Drawing.Image.FromFile("C:\temp\" + ColourList.SelectedItem + "t.bmp") So if we look at the code above the following actions are happening, the value of the imagebox TeeImage.Image will be set to the location of a file set out in the ( ) the path is selected then the value of the selected option in the drop down box "ColourList.SelectedItem" is pasted in to the path name then the final part is added "t.bmp"


Designs and Designing Tools

We must remember when creating a system the importance of our design documents, these will provide the basis of infomation that will assit the users and also the developer, as in some cases you may only design a system and never create it as a specailist person may do that for you. However they will need as much information as is possible to get the correct naming of tools and the correct setting of properties and attributes.

The use of a storyboard is the first step to a healthy project. This provides the detail to location, size and presentation of the system, this is like the architects plans to a house before it is built. At this stage a desiger could find that a client would like to change the layout as they didnt like the feel of the program, or they could add further elements to it. It is also key to do this stage first as this is more time efficent that creating the application on a conversation as you can simply rub out an element and move it elsewhere in seconds and not have to worry about its links to other elements in the system.

#

Table of Tools

In this area we outline the tools that will be required on the form/ program and the naming of them and if there are any special properties that need to be changed or selected. The best way to present this information is how it has been displayed in your tutorial worksheets todate.

Object Property Value
Label1 Name LblIncrement
text Increment
- - -
Label2 Name LblDecrease
text decrease
#

What is the #
#
5 min's

#

#



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

Files that support this week

English: 0
0
Assessment: 0

0
Learning Outcomes:
Awarding Organisation Criteria:
Maths:
Stretch and Challenge:
E&D / BV
Homework / Extension:
ILT
  →  →  →  →  →  →
Week 8 T&L Activities:

System


Key features

#

What is the #
#
5 min's

#

#



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

Files that support this week

English: 0
0
Assessment: 0

0
Learning Outcomes:
Awarding Organisation Criteria:
Maths:
Stretch and Challenge:
E&D / BV
Homework / Extension:
ILT
  →  →  →  →  →  →