Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.

Slides:



Advertisements
Similar presentations
Chapter 1: An Introduction to Visual Basic 2012
Advertisements

Tutorial 8: Developing an Excel Application
© by Pearson Education, Inc. All Rights Reserved. continued …
 2006 Pearson Education, Inc. All rights reserved Introduction to the Visual C# 2005 Express Edition IDE.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
Chapter 2 User Interface Design Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Chapter 8: String Manipulation
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2005: Reloaded Second Edition
Tutorial 11 Using and Writing Visual Basic for Applications Code
IE 411/511: Visual Programming for Industrial Applications
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
BIM211 – Visual Programming Objects, Collections, and Events 1.
Chapter 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Starting Out with Visual Basic.NET 2 nd Edition Chapter 2 Creating Applications With Visual Basic.NET.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Productivity Programs Common Features and Commands.
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.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
Key Applications Module Lesson 21 — Access Essentials
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
BIL528 – Bilgisayar Programlama II Introduction 1.
The PictureBox Control Prefix Prefix – pic Image Property PictureBox Image Property – Changes the image or file that appears inside of the PictureBox SizeMode.
Visual Basic.NET BASICS Lesson 3 Events and Code.
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”
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
COMPUTER PROGRAMMING I SUMMER 2011 Objective 8.02 Apply Procedures to Create Picture Boxes using Images. (5%)
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
CSC115 Introduction to Computer Programming Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA 19383
2-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
PYP002 Intro.to Computer Science Microsoft Word1 Lab 04 - a Microsoft Windows Applications Common Features.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Visual Basic A Quick Tutorial VB Review for ACS 367.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
 You won’t write a single line of program code.  Instead, you’ll use visual programming techniques.  Visual Studio processes your actions (such as mouse.
2-1 Chapter 2 Using VB.NET to Create a First Solution.
Programming with Microsoft Visual Basic 2012 Chapter 1: An Introduction to Visual Basic 2012.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter One An Introduction to Visual Basic 2008.
Microsoft Visual Basic 2010 CHAPTER FOUR Variables and Arithmetic Operations.
Chapter 2: The Visual Studio .NET Development Environment
Chapter 1: An Introduction to Visual Basic 2015
Variables and Arithmetic Operations
How to design a Windows Forms application
Objective 8.02 Apply Procedures to Create Picture Boxes using Images.
Variables and Arithmetic Operations
Microsoft Visual Basic 2005 BASICS
Chapter 2 User Interface Design
Presentation transcript:

Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code

Microsoft Visual Basic 2005 BASICS2 Objectives Describe events and how events are key to Windows programs. Access the Code window. Add code to a command button. Add a picture to a form.

Microsoft Visual Basic 2005 BASICS3 Objectives (cont.) Set picture properties. Use code to set properties. Set the Cancel and Default command button properties. Create a stand-alone Windows program.

Microsoft Visual Basic 2005 BASICS4 Events Event-driven system  Computer is constantly waiting for the user to take some action With the mouse, keyboard, or other device Action triggers an event  Software in the computer attempts to find something to do with that action

Microsoft Visual Basic 2005 BASICS5 Events (cont.) When you create an object  It is up to you to write the code that will handle the events. Event procedure  Code that handles a specific event

Microsoft Visual Basic 2005 BASICS6 Accessing the Code Window Add code to a command button  Open the form that contains the command button.  Double-click the command button. The Code window will appear. Subroutine  Section of code to perform a specific task

Microsoft Visual Basic 2005 BASICS7 Accessing the Code Window (cont.)

Microsoft Visual Basic 2005 BASICS8 Adding Code to a Command Button Add code to the Code window  Simply enter the code from the keyboard. You can insert and delete text and use cut, copy, and paste. IntelliSense technology  Anticipates what you are about to key Completes your statement for you Visual Basic is not case sensitive.

Microsoft Visual Basic 2005 BASICS9 Adding Code to a Command Button (cont.)

Microsoft Visual Basic 2005 BASICS10 Adding a Picture to a Form PictureBox control  Provides a framework for displaying a picture on a form

Microsoft Visual Basic 2005 BASICS11 Adding a Picture to a Form (cont.)

Microsoft Visual Basic 2005 BASICS12 Adding a Picture to a Form (cont.)

Microsoft Visual Basic 2005 BASICS13 Adding a Picture to a Form (cont.)

Microsoft Visual Basic 2005 BASICS14 Adding a Picture to a Form (cont.)

Microsoft Visual Basic 2005 BASICS15 Setting Image Properties Image controls  Have an extensive set of properties that can be changed

Microsoft Visual Basic 2005 BASICS16 The Name Property Name property  Names the PictureBox control The pic prefix is often used when naming PictureBox controls.

Microsoft Visual Basic 2005 BASICS17 The SizeMode Property SizeMode property  Allows you to specify what to do when picture and space available do not match Values  Normal  Center  StretchImage  AutoSize

Microsoft Visual Basic 2005 BASICS18 The SizeMode Property (cont.)

Microsoft Visual Basic 2005 BASICS19 The SizeMode Property (cont.)

Microsoft Visual Basic 2005 BASICS20 The Visible Property Visible property  Gives you control over when a picture is visible to the user

Microsoft Visual Basic 2005 BASICS21 Use Code to Set Properties Change a property by specifying  Name of the control  Property  Value

Microsoft Visual Basic 2005 BASICS22 Use Code to Set Properties (cont.) The item to the right of the dot is called a method. In object-oriented programming  You do not actually set the property.  You ask an object to set its own property by sending it a message.

Microsoft Visual Basic 2005 BASICS23 Use Code to Set Properties (cont.)

Microsoft Visual Basic 2005 BASICS24 Use Code to Set Properties (cont.)

Microsoft Visual Basic 2005 BASICS25 Adding Access Keys to Command Buttons Access key  Declared in the Text property in Visual Basic programs  Allows a user to activate a command without using a mouse

Microsoft Visual Basic 2005 BASICS26 Setting the AcceptButton and CancelButton Form Properties AcceptButton property  Names the command button to be used when the user presses the Enter key CancelButton property  Names the command button to be used when the user presses the Esc key

Microsoft Visual Basic 2005 BASICS27 Summary Windows is an event-driven environment. In an event-driven system, the user triggers events that control the work. To control what happens when an event occurs, you must write event procedures for each event that you want to handle. To access the Code window, double-click an object, such as a command button.

Microsoft Visual Basic 2005 BASICS28 Summary (cont.) Visual Basic code is written in sections called subroutines. Adding code is much like working in a word processor. The basic text-editing features are available. In addition, Visual Studio 2005 has IntelliSense features to help format your program code.

Microsoft Visual Basic 2005 BASICS29 Summary (cont.) The End statement ends a program. The PictureBox tool allows you to add a PictureBox control to a form. Using the (Name) property, you can give a PictureBox control a name. That name will be used when you refer to the control in code.

Microsoft Visual Basic 2005 BASICS30 Summary (cont.) Setting the SizeMode property to StretchImage causes a picture to resize to fit the dimensions of the PictureBox control. Setting the SizeMode property to AutoSize causes a PictureBox control to resize to fit the picture loaded into it. The Visible property controls whether an object is shown or hidden.

Microsoft Visual Basic 2005 BASICS31 Summary (cont.) Setting properties in code is one of the most common uses for Visual Basic code. Setting properties in code allows you to change properties while a program runs. A command button with an ampersand (&) in front of a letter in the Text property causes that letter to become an access key.

Microsoft Visual Basic 2005 BASICS32 Summary (cont.) The command button named in the form’s AcceptButton property will be activated when the user presses the Enter key. The command button named in the form’s CancelButton property will be activated when the user presses the Esc key.