Chapter 31 Fundamentals of Programming in Visual Basic (VB) Visual Basic Events Simple Statement.

Slides:



Advertisements
Similar presentations
Chapter 2 –Visual Basic, Controls, and Events
Advertisements

Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Eight Sub and Function Procedures.
Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Chapter 2 –Visual Basic, Controls, and Events
Introduction to Visual Basic Programming. Lecture Outline History What is Visual Basic First Look at the VB 6.0 Environment Some VB Terminology Our first.
Compunet Corporation Programming with Visual Studio.NET GUI Week 13 Tariq Aziz and Kevin Jones.
The Initial Visual Basic Screen
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.
CS0004: Introduction to Programming Events. Review  Event Procedure  A set of instructions to be executed when a certain event happens.  Many event-driven.
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
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.
CS0004: Introduction to Programming Variables – Numbers.
05/09/ Introducing Visual Basic Sequence Programming.
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.
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
Chapter 8: Writing Graphical User Interfaces
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 1B Introduction (Tutorial)
CIS 115 Lecture 3.  Forms  Form properties  Controls  Control properties  Event Driven Programming  Form Events  Control Events  Event Handlers.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures.
R EVIEW OF C HAPTER 1 1. Trouble installing/accessing Visual Studio? 2.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET VB.NET Controls VB.NET Events Numbers Strings Input and Output.
Chapter 3 - VB 2005 by Schneider1 Chapter 3 – Fundamentals of Programming in Visual Basic 3.1 Visual Basic Controls 3.2 Visual Basic Events 3.3 Numbers.
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.
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.
Chapter 2 –Visual Basic, Controls, and Events
1 Chapter 3 – Fundamentals of Programming in Visual Basic 3.1 Visual Basic Controls 3.2 Visual Basic Events 3.3 Numbers 3.4 Strings 3.5 Input and Output.
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.
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.
3.2 VB.NET Events An Event Procedure Properties and Event Procedures of the Form Tab Order of Controls Exercises.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET Part I VB.NET Controls VB.NET Events.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Inventory Application.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
7-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
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.
List Boxes and Combo Boxes Provides a list of items to select from Various styles — choose based on Space available Need to select from an existing list.
CIS 338: Events Dr. Ralph D. Westfall April, 2011.
 ASP.NET provides an event based programming model that simplifies web programming  All GUI applications are incomplete without enabling actions  These.
Chapter 31 Fundamentals of Programming in Visual Basic (VB) Visual Basic Events Simple Statement.
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.
Introduction to Computer CC111 Week 10 Visual Basic 3 1.
ALMAJMA'AH UNIVERSITY College of Science and Humanitarians Studies in Alghat Information Technology Section (211Tal course) 1.
Chapter 8 Multiple Forms, Modules, and Menus. Introduction This chapter demonstrates how to: – Add multiple forms to a project – Create a module to hold.
Visual Basic Fundamental Concepts
Chapter 3 – Fundamentals of Programming in Visual Basic
Chapter 1: An Introduction to Visual Basic 2015
Chapter 8: Writing Graphical User Interfaces
Do Now: What are the three steps to writing a Visual Basic Program?
Introduction to VB programming
Visual Basic..
Fundamentals of Programming in VB.NET
The List Box Control Items can be placed into the list at design time or run time The Sorted property causes items in the list to be sorted automatically.
Building an Application in the Visual Basic .NET Environment
CIS16 Application Development and Programming using Visual Basic.net
Project Design, Forms and Buttons
Fundamentals of Programming in VB.Net
Introduction to Programming
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:

Chapter 31 Fundamentals of Programming in Visual Basic (VB) Visual Basic Events Simple Statement

Chapter 32 Event An event is an action, such as the user clicking on a button Usually, nothing happens in a Visual Basic program until the user does something and generates an event. What happens is determined by statements. Visual Basic Events

Chapter 33 Assignment Statements Assign a value to a property. General Form: source = value A value on the right- hand side of = is assigned to the left- hand size of =.

Chapter 34 Sample Statements txtBox.ForeColor = Color.Red txtBox.Visible = True txtBox.Text = “Hello World” General Form: controlName.property = setting Value represented by setting is stored into controlName.property Color is a structure allowing us to specify various colors

Chapter 35 Lab Refers to the examples in the Lab

Chapter 36 Sample Form txtFirst txtSecond btnRed

Chapter 37 Focus When you click on a text box, a cursor appears in the text box, and you can type into the text box. Such a text box is said to have the focus. If you click on another text box, the first text box loses the focus and the second text box receives the focus.

Chapter 38 Examples of Events btnShow.Click txtBox.TextChanged txtBox.Leave General Form: controlName.event This event occurs when a mouse is clicked on the button btnShow This event occurs when user changes the text of txtBox This event occurs when the input focus leaves txtBox

Chapter 39 The three steps in creating a Visual Basic program: 1.Create the interface; that is, generate, position, and size the objects. 2.Set properties; that is, configure the appearance of the objects. 3.Write the code that executes when events occur.

Chapter 310 Code Window Method Name box Class Name box Page tab Page tab: 1. frmDemo.vb is a code window 2. frmDemo.vb [design] is a design window (to manipulate the window appearance)

Chapter 311 Structure of an Event Procedure Private Sub objectName_event(...) Handles objectName.event statements End Sub Header (...) is filled automatically with (ByVal sender As System.Object, ByVal e As System.EventArgs ) To specify which event will trigger this procedure. The name of the procedure

Chapter 312 Code Window Method Name box Class Name box Page tab

Chapter 313 Create an Outline for an Event Procedure; i.e. header and End Sub 1. Double-click on a control or 2. Use the Class Name and Method Name boxes. (We primarily use the first method.)

Chapter 314 Sample Form txtFirst txtSecond btnRed Double Click on txtFirst

Chapter 315 Code for Walkthrough Public Class frmDemo Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged End Sub End Class TextChanged event occurs when the user changes the text of a TextBoxTextBox

Chapter 316 Code for Walkthrough Public Class frmDemo Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged txtFirst.ForeColor = Color.Blue End Sub End Class

Chapter 317 IntelliSense Automatically pops up to give the programmer help.

Chapter 318 Code Window Click tab to return to Form Designer

Chapter 319 Sample Form txtFirst txtSecond btnRed Double-click on btnRed

Chapter 320 Code for Walkthrough Public Class frmDemo Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged txtFirst.ForeColor = Color.Blue End Sub Private Sub btnRed_Click(...) Handles btnRed.Click End Sub End Class

Chapter 321 Code for Walkthrough Public Class frmDemo Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged txtFirst.ForeColor = Color.Blue End Sub Private Sub btnRed_Click(...) Handles btnRed.Click txtFirst.ForeColor = Color.Red End Sub End Class

Chapter 322 Event Procedure txtFirst.Leave Select txtFirst from Class Name box drop-down list. Select Leave from Method Name box drop-down list.

Chapter 323 Code for Walkthrough Private Sub txtFirst_Leave(...) Handles txtFirst.Leave End Sub Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged txtFirst.ForeColor = Color.Blue End Sub Private Sub btnRed_Click(...) Handles btnRed.Click txtFirst.ForeColor = Color.Red End Sub

Chapter 324 Code for Walkthrough Private Sub txtFirst_Leave(...) Handles txtFirst.Leave txtFirst.ForeColor = Color.Black End Sub Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged txtFirst.ForeColor = Color.Blue End Sub Private Sub btnRed_Click(...) Handles btnRed.Click txtFirst.ForeColor = Color.Red End Sub

Chapter 325 Header of Event Procedure Private Sub btnRed_Click(…) Handles btnRed.Click Identifies the event that triggers the procedure Name, can be changed. Private Sub Button_Press(…) Handles btnRed.Click

Chapter 326 Handling Multiple Events Private Sub Button_Click(...) Handles btnRed.Click, txtSecond.Leave txtFirst.ForeColor = Color.Red End Sub Event procedure can be invoked by two events.

Chapter 327 Altering Properties of the Form The following won't work: frmDemo.Text = "Demonstration" The form is referred to by the keyword Me. Me.Text = "Demonstration“