CIS 338: Events Dr. Ralph D. Westfall April, 2011.

Slides:



Advertisements
Similar presentations
VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming.
Advertisements

Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Chapter 2 –Visual Basic, Controls, and Events
VB Controls and Events Week 7: Picture Box, Image Box, Option, Check box, Mouse over, Frames, Shapes.
Mouse draw Using the mouse and a palette to make a picture.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
110-C1 Chapter 2 of the text: _ text boxes, group boxes, check boxes, radio buttons, picture boxes _ defining access keys tab sequence setting the focus.
Chapter 2 –Visual Basic, Controls, and Events
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
Controls General Discussion. VB Controls Visual Basic Controls A control is the generic name for any object placed on a form Controls may be images,
CS0004: Introduction to Programming Events. Review  Event Procedure  A set of instructions to be executed when a certain event happens.  Many event-driven.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Introduction to VB.NET Tonga Institute of Higher Education.
Unit 20: Event Driven Programming
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
CS 0004 –Lecture 1 Wednesday, Jan 5 th, 2011 Roxana Gheorghiu.
CIS 338: Creating ActiveX Controls Dr. Ralph D. Westfall March, 2003.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Menus,MonthCalender, DateTimePicker, MDI,Tree View, List View,
Chapter 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Menus,MonthCalender, DateTimePicker, MDI,Tree View, List View,
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
Timer, Animation Responding to Mouse & Keyboard Lab 7 7 McGraw-Hill© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Chapter 2 –Visual Basic, Controls, and Events
Visual Basic.NET BASICS Lesson 3 Events and Code.
Chapter 2 - VB 2008 by Schneider1 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
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.
What is Visual Basic.NET? 110 B-1 e.g. a word processor doesn’t do anything until the user clicks on a button, types text... A programming language that.
3.2 VB.NET Events An Event Procedure Properties and Event Procedures of the Form Tab Order of Controls Exercises.
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET Part I VB.NET Controls VB.NET Events.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Chapter 31 Fundamentals of Programming in Visual Basic (VB) Visual Basic Events Simple Statement.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
Chapter 31 Fundamentals of Programming in Visual Basic (VB) Visual Basic Events Simple Statement.
CIS 338: VB.NET Printing Dr. Ralph D. Westfall May, 2011.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
21/03/ Working with Controls Text and List Boxes.
Programming with Visual Basic.NET. Quick Links Program Code The Code Window The Event Procedure Assignment Statements Using AutoList Radio Buttons Buttons.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Chapter 2 - VB 2008 by Schneider1 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Visual Basic Fundamental Concepts
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Chapter 1: An Introduction to Visual Basic 2015
3.01 Apply Controls Associated With Visual Studio Form
Introduction to VB6 Week 1 3/2/2004 PPCC - Introduction to VB6
Using Procedures and Exception Handling
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Visual Basic..
CIS 338: Images on Forms Dr. Ralph D. Westfall May, 2009.
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Presentation transcript:

CIS 338: Events Dr. Ralph D. Westfall April, 2011

What Is an Event? an event is when something happens common user events start the program press a key click the mouse move the mouse close/end the program

Other Events events don't have to be from local user time (update virus checker every Wednesday at 10 AM) message arrives E:\ drive not ready  event happens when program tries to read or write the missing CD

Event Driven Programming interactive programs respond to events generated by users, by the operating system, possibly by sensors, or by the application itself object oriented languages are well suited for writing interactive programs event "listeners" can be added to Java objects, are built into many VB.NET ones

Common Controls Events Click – with left mouse button MouseDown – click with either button MouseMove – cursor moved over object Enter – object becomes "active" user tabs to it, or clicks on it (GotFocus*) Leave – loses active status (LostFocus*) KeyDown – key pressed when object has focus (instruction: "press any key") * VB6 (still works, but don't use!)don't use!

Form Events Resize – first thing that happens when a form is loaded also happens when user or code changes its size Move – next thing that happens also happens when user drags the form Load – goes into memory not visible yet (run MsgBox out of Load) Activated – when form is shown or gets focus if already visible useful when have multiple forms

Form Events - 2 Deactivate – when hidden or loses focus Closing – when being removed from memory Closed – when destroyed completely by code, or when a Visual Basic.NET application ends

VB.NET Event Procedures Windows (operating system) detects an event and sends a message to VB.NET VB.NET looks for code to handle it Private Sub btnExit_Click(etc.) Handles btnExit.Click 'code runs on a click event End End Sub btnExit = current button name.Click = Event

Handling Multiple Controls a procedure can handle multiple events Private Sub ProcessEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.Enter, txtAddress.Enter [can test Name of control or Tag property defined by programmer to handle some aspects differently] End Sub 'more informationmore information

Creating an Event Procedure start VB and draw a control(s) on form open Code window View>Code, click Solution Explorer's View Code Icon, or [right click form]>View Code select control in left ComboBox select event in right ComboBox write in code to handle this event in the Sub that VB.NET creates for you

Event Procedure Example start a new Windows Application in code window, select (frmName Events) and MouseMove event in top ComboBoxes add following code to the Sub, and then move mouse over Form when running Me.Text = "X=" & e.X & " Y=" & e.Y 'Me means this formNotes

Code to Cause Event to Happen create an event procedure (previous slides) code a subroutine, or use an existing one put in a line of code to generate the event Private Sub RespondSomeEvent( [etc. ]) Call Button1_Click(sender, e) 'args required End Sub 'Call is optional useful when something needs to happen just after something else happens in above code, program clicks a button when some event specified by user happens 'previous page notes

Exercise add a ListBox to a form add some Items in the Properties double click inside the ListBox to create a Sub to handle the event when a different item is selected add a MsgBox to the Sub to show the new item selection (see code below if can't find necessary code through Intellisense)