CS0004: Introduction to Programming Events. Review  Event Procedure  A set of instructions to be executed when a certain event happens.  Many event-driven.

Slides:



Advertisements
Similar presentations
What Was I Thinking??. Key Terms 1. Control 1. Control 2. Design Mode 2. Design Mode 3. Event 3. Event 4. Form 4. Form 5. Interface 5. Interface 6. Properties.
Advertisements

Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
CS7026 jQuery Events. What are Events?  jQuery is tailor-made to respond to events in an HTML page.  Events are actions that can be detected by your.
Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Chapter 6 Multiform Projects Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Visual Basic Project Files:.VBP file: Project File: a small text file that contains the names of other files in the project, as well as some information.
Chapter 2 –Visual Basic, Controls, and Events
Compunet Corporation Programming with Visual Studio.NET GUI Week 13 Tariq Aziz and Kevin Jones.
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
CIS 115 Lecture 2.  Visual Studio 2005 Professional Edition (Requires Windows XP Pro)  MSDN Library for Visual Studio 2005 Available from MSDNAA.
1 Introduction to Human Computer Interaction  Livecode Overview  Based on Livecode User Guide from RunRev Ltd. (2010) 
Chapter 2 –Visual Basic, Controls, and Events
Apply Sub Procedures/Methods and User Defined Functions
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.
Visual Basic Chapter 1 Mr. Wangler.
CS0004: Introduction to Programming Variables – Numbers.
05/09/ Introducing Visual Basic Sequence 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.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
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,
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Menus,MonthCalender, DateTimePicker, MDI,Tree View, List View,
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Chapter 3 – Fundamentals of Programming in VB.NET VB.NET Controls VB.NET Events Numbers Strings Input and Output.
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
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.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Chapter 2 –Visual Basic, Controls, and Events
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Multiform Projects.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
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.
3.2 VB.NET Events An Event Procedure Properties and Event Procedures of the Form Tab Order of Controls Exercises.
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 for Application - Microsoft Access 2003 Programming applications using Objects.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
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.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
IMS 3253: Forms, Controls, Properties, Events 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Program Elements Assignment.
CIS 338: Events Dr. Ralph D. Westfall April, 2011.
Chapter 31 Fundamentals of Programming in Visual Basic (VB) Visual Basic Events Simple Statement.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
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.
ALMAJMA'AH UNIVERSITY College of Science and Humanitarians Studies in Alghat Information Technology Section (211Tal course) 1.
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Chapter 1: An Introduction to Visual Basic 2015
Visual Basic Code & No.: CS 218
Chapter 8: Writing Graphical User Interfaces
Do Now: What are the three steps to writing a Visual Basic Program?
Apply Procedures to Develop Menus, List Box and Combo Box Objects
CIS16 Application Development Programming with Visual Basic
Fundamentals of Programming in VB.Net
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
GUI Programming in Visual Studio .NET
Presentation transcript:

CS0004: Introduction to Programming Events

Review  Event Procedure  A set of instructions to be executed when a certain event happens.  Many event-driven programs can be divided into three important sections or layers:  Presentation Layer  Anything the user sees and how the user interacts with a program.  Logic Layer  How the program acts when it receives events.  Data Access Layer  Allows simple access to persistent storage (like a database). We probably won’t be doing this in this course.

Review  When you run your Visual Basic program the following things happen: 1. Your program monitors the controls in the window to detect any event that a control can recognize (mouse movements, clicks, keystrokes, etc.) 2. When your program detects an event, it examines the code to see if you’ve written an even procedure for it. 3. If you have written an event procedure, the instructions in the procedure are executed and it goes back to step If you have not written an event procedure, it ignores the event and goes back to step 1.

Review  The naming (value of the name property) of controls should indicate what it is and what it does. ObjectPrefixExample FormfrmfrmPayroll ButtonbtnbtnComputeTotal LabellbllblAddress Text BoxtxttxtCity List BoxlstlstOutput

Events  Now that we have an interface, we can have our controls act on events.  For now, we will just change the properties of controls with our events  The basic form of setting a property of a control: controlName.property = setting  controlName – the name of the control whose property you want to change (ex. txtName)  property – the property you want to change (ex. ForeColor)  setting – value for which you want to set the property

Events  Examples: txtBox.Text = “Hello”  Displays “Hello” in the text box btnButton.Visible = True  Makes the button visible txtBox.ForeColor = Color.Red  Makes the text color in the text box red frmMain.Text = “My Form”  Will NOT work in the code for frmMain. You must use the word Me (because the form is referring to itself) Me.Text = “My Form”  These lines of code (statements) are called Assignment Statements.

Event Procedures  To give the controls function when events occur, we need to write our code in event procedures.  Note: I will often call event procedures, “event handlers”.  To view the code right click on the form and select “View Code”  To make an event procedure you can: 1. Double click on the control (creates the default event procedure for the control) 2. Click on the control then click the “Events” button at the top of the Properties Window  This will create the code for the event procedure.

Event Procedures  An event procedure looks something like this: Private Sub btnButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnButton.Click ‘Code goes here End Sub  Don’t worry about all the details of this code!  There’s only two parts you need to worry about: 1. btnButton_Click is the name of the event procedure 2. btnButton.Click tells the procedure to listen for the click event on the button btnButton.  The most of the rest are keywords used to describe the procedure  Keywords are words that have a particular meaning in VB  These are reserved, meaning they can’t be used for other purposes (this will be clearer when we talk about variables)

Event Procedures  A single event handler can listen for multiple different events. Private Sub btnButton_Click(…) Handles btnButton1.Click, btnButton2.Click ‘Code goes here End Sub  So the code inside of the procedure will be executed if either btnButton1 or btnButton2 is clicked.

IntelliSense  When you start typing code in Visual Studio, a system called IntelliSense will attempt to assist you by giving you options to complete your code.  This limits the amount of code you have to memorize.  When an item is highlighted in the drop-down supplied by IntelliSense, a tool tip is supplied next to it.  You can select an item in the menu by clicking on it, pushing enter, or tab.  If the IntelliSense drop-down gets in the way, you can hold down the control key to make it transparent.

Default Events  When double clicking on a control, you will get the event procedure for the control’s default event.  The some default events are as follows: ControlDefault Event formLoad buttonClick labelClick list boxSelectedIndexChanged text boxTextChanged

Some Events  Click – Useful for buttons.  DoubleClick – Not available for buttons, but can be used for labels, text boxes, etc.  Focus  Enter – Event raised when control first receives focus  Leave – Event raised when control first loses focus  Keys – Useful for text boxes.  KeyDown – Event raised when a key is first pressed  KeyUp – Event raised when a key is first released  Key Pressed – Event raised when the control has focus and a key is pressed and released.  Mouse  MouseDown – Event raised when the a mouse button is first pressed while over a control  MouseUp - Event raised when the a mouse button is first released while over a control  MouseEnter – Event raised when the mouse enters a visible part of the control  MouseLeave – Event raised when the mouse leaves a visible part of the control  MouseHover – Event raised when a mouse remains stationary over a control  Property Changed – When the programmer or the user changes a property of a control an event is raised  TextChanged – Event raised when the value of the “Text” property is changed

Opening a Project  To open a saved VB project: 1. Click on “Project/Solution” from the “File” menu under “Open”. 2. Navigate to where you saved your project. 3. Double Click on the folder that was created by Visual Studio when you saved (it should have the same name that you named you project) 4. Double click on the “.sln” file (it should have the same name that you named you project).  Also, if you successfully debug you program, it will create an executable file inside of your Debug directory. To get to it: 1. Double Click on the folder in the same folder as your “.sln” file. 2. Double Click on the “bin” folder. 3. Double Click on the “Debug” folder. 4. It is the “.exe” file in the “Debug” folder.  An executable file is a file for the specific purpose of running your program.