Event Handling Tonga Institute of Higher Education.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Information System Design Lab 5&6. User Interface Design.
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
CSI 3120, Exception handling, page 1 Exception and Event Handling Credits Robert W. Sebesta, Concepts of Programming Languages, 8 th ed., 2007 Dr. Nathalie.
1 Pertemuan 02 Visual Basic Environment and Control Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Writing GUI Applications An introduction with Java.
Installation on Windows Vista/Windows 7 NOTE: Installation on Windows Vista can differ depending on the version of Windows installed​ ​ In most computers.
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Not in Text CP212 Winter No VBA Required “Regular” Programming traditional programming is sequential in nature o one command executed after another.
Visual Basic Chapter 1 Mr. Wangler.
Introduction to VB.NET Tonga Institute of Higher Education.
Unit 20: Event Driven Programming
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
CS 0004 –Lecture 1 Wednesday, Jan 5 th, 2011 Roxana Gheorghiu.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Event Driven Programming
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Intro to More Controls in C#. C# Demonstration We already touched on labels and buttons Ad-hoc demo of controls – Textboxes Multiline – Checkbox – Radiobutton.
Intro to More Controls in C#. C# Demonstration We already touched on labels and buttons Ad-hoc demo of controls – Textboxes Multiline – Checkbox – Radiobutton.
Introduction to Windows Programming
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Controls. Adding Controls to Form -You can pick controls from the toolbox. -To add the controls from Toolbox to the Form You have be in design view. -To.
Digital Electronics and Computer Interfacing Tim Mewes 4. LabVIEW - Advanced.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved. - edited by Maysoon Al-Duwais1.
What is Programming? Computer programming is about telling the computer what it is we want it to do We tell the computer what we want it to do by sending.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
CSC 157 (Blum)1 Hello World. CSC 157 (Blum)2 Start/Programs/Microsoft Visual Studio.NET 2003/Microsoft Visual Studio.NET 2003.
Object Oriented Programming.  Interface  Event Handling.
GUIs Basic Concepts. GUI GUI : Graphical User Interface Window/Frame : a window on the screen Controls/Widgets : GUI components.
You will need Dev C++ to help you with this project. If you do not already have this programming tool on your device you can visit
Error Handling Tonga Institute of Higher Education.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
VB.NET and Databases. ADO.NET VB.Net allows you many ways to connect to a database. The technology used to interact with a database or data source is.
CIS 338: Events Dr. Ralph D. Westfall April, 2011.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
Procedural programming Procedural programming is where you specify the steps required. You do this by making the program in steps. Procedural programming.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Exception Handling. VB.NET has an inbuilt class that deals with errors. The Class is called Exception. When an exception error is found, an Exception.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Enhanced Car Payment Calculator Application Introducing Exception Handling.
Scratch for Interactivity
Introduction to Event-Driven Programming
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
Event-driven programming
Event loops 16-Jun-18.
Unit 20: Event Driven Programming
Lesson 1: Buttons and Events – 12/18
Chapter 2 Visual Basic Interface
Event Driven Programming
Event Driven Programming
Event loops.
Event Driven Programming
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Event loops 8-Apr-19.
Tonga Institute of Higher Education
Event loops.
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

Event Handling Tonga Institute of Higher Education

Event Driven Programs Event Driven Programs – The program responds to a user event  Event - An action or occurrence detected by a program User  Clicking a mouse button  Pressing a key System  Running out of memory  An error occurring  For example, your program might work like this: Show a form with a welcome message. The form will also contain a textbox, OK button and instructions to enter their name and click the Ok button. Wait for the user to respond When the user performs an action,  If the user clicks the X in the top right corner, quit the program  If the user typed in their name and pressed the OK button, show a message that you are happy to meet them  Gives more freedom to the user. It reacts to the user’s actions  Gives user the impression that they are in control Forms are event driven!

Current Situation We learned how to display a graphical user interface However, it doesn’t do anything Event – Something that is triggered by the user of a GUI Handler – Code that can detect and respond to events

Creating Events VS.NET automatically creates events for you Double clicking on the control will automatically create code to handle the most common event Code in this place will be executed when the button is clicked This place is called a subroutine

Demonstration Creating the most common event for a control

Creating Uncommon Events - 1 To create an uncommon event 1. View the code 2. Select the control you wish to create an event for 3. Select the event you wish to create

Creating Uncommon Events - 2 To create an uncommon event 1. View the code 2. Select the control you wish to create an event for 3. Select the event you wish to create

Demonstration Creating an uncommon event for a control

Creating Events When you using the techniques previously discussed, VS.NET automatically creates events in your code. If you want, you can create this code yourself Keyword indicates that this method handles an event Name of the Control The Event handled

Demonstration Working with Event Code

MessageBox An attention getter Displays information to the user Forces user to do something before continuing MessageBox.Show("Hi")

Demonstration Displaying a MessageBox when a button is clicked

Class Activity 1. Double Click on the button 2. Add the following code to the subroutine: MessageBox.Show("Hello World!") 3. Run the application

Opening A Form With Code Sometimes, we need to open a form when an event occurs. (Example: Open a student form when a button is clicked)

Demonstration Opening a form with code

Hiding a Form vs. Exiting an Application We can use events to hide and show forms  frmCustomer.visible = false This is different from exiting an application  Application.Exit A program can hide all of it’s forms but still be running. In this case, the program is not usable and is needlessly using the computer’s resources If we are using VS.NET, the program will always stop running when we press the stop button However, when we are using the.exe file, we must use the task manager to shut down programs that are running without any forms showing

Demonstration Hiding a Form vs. Exiting an Application

Error when Quitting a Program Due to Network Configuration Application.Exit does not work properly when a project is located on a network drive You will get this error It will work if the program is run locally We don’t need to worry about it

Demonstration Error Demonstration