R EVIEW OF C HAPTER 1 1. Trouble installing/accessing Visual Studio? 2.

Slides:



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

CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Chapter 1: An Introduction to Visual Basic 2012
Using Macros and Visual Basic for Applications (VBA) with Excel
© by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
Chapter 2 –Visual Basic, Controls, and Events
Chapter 31 Visual Basic Controls A Form is a windows-style screen displayed by Visual Basic programs. In a form, a programmer can create objects in a form.
Chapter 1- Visual Basic Schneider 1 Chapter 1 An Introduction to Computers and Visual Basic.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Chapter 2 –Visual Basic, Controls, and Events
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 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Microsoft Visual Basic 2005: Reloaded Second Edition
Chapter 1 P. 1 Writing Windows applications with Visual Basic Figure 1.1 The first program works as follows: (These operations can be performed in any.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
IE 411/511: Visual Programming for Industrial Applications
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 2 Welcome Application Introducing the Visual Basic 2008 Express Edition IDE.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
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.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface 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
Chapter Two Creating a First Project in Visual Basic.
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.
Chapter 2 – Introduction to the Visual Studio .NET IDE
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
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.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development 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.
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.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET 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.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
ALMAJMA'AH UNIVERSITY College of Science and Humanitarians Studies in Alghat Information Technology Section (211Tal course) 1.
Chapter 1: An Introduction to Visual Basic 2015
Chapter 2 – Introduction to the Visual Studio .NET IDE
An Introduction to Computers and Visual Basic
3.01 Apply Controls Associated With Visual Studio Form
3.01 Apply Controls Associated With Visual Studio Form
An Introduction to Computers and Visual Basic
Do Now: What are the three steps to writing a Visual Basic Program?
Chapter 3 Fundamentals of Programming in Visual Basic 3
Chapter 2 – Introduction to the Visual Studio .NET IDE
CIS16 Application Development Programming with Visual Basic
An Introduction to Computers and Visual Basic
Fundamentals of Programming in VB.Net
Presentation transcript:

R EVIEW OF C HAPTER 1 1

Trouble installing/accessing Visual Studio? 2

R EVIEW Computer a device that can perform calculations and make logical decisions much faster than humans can Computer programs a sequence of instructions Input—Process—Output (data—manipulate—results) Hardware: physical components (keyboard, screen, mouse, hard drive, memory, DVDs, CPU—Central Processing Unit) Software: programs that run on a computer 3

R EVIEW Programmers vs. Users Computer languages: Machine language: computers understand. High-level language: resembles everyday English. Compilers convert it into machine language. (Visual Basic, C, C++, Java, C#, Fortran, COBOL, …)

R EVIEW Algorithm: a step by step series of instructions to solve a problem Visual Basic.NET is: Event-driven Object-oriented User-friendly (GUI-based)

C HAPTER 2 Visual Basic, Controls, and Events 6

V ISUAL B ASIC, C ONTROLS, AND E VENTS 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual Basic Events 7

V ISUAL B ASIC 2010 Before VB, a window required hundreds of lines of code Now Fewer instructions Consistent Less time User-friendly 8

V ISUAL B ASIC 2010 Language used to create Windows applications. Provides a Graphical User Interface or GUI. The sequence of instructions executed in the program is controlled by events. 9

B EFORE VB 10

B EFORE VB Program complicated, unfriendly Required parameters Once input was entered, hard to go back 11

H OW TO D EVELOP A VB A PPLICATION Design the Interface for the user Literally draw the GUI Drag buttons/text boxes/etc onto form Determine which events the controls on the window should recognize Write the code for those events. Test 12

W HAT HAPPENS WHEN PROGRAM IS RUNNING 1. VB monitors the controls for events 2. If event occurs, it runs procedures assigned to that event 3. If no event exists, it goes back to #1 13

D IFFERENT V ERSIONS OF V ISUAL B ASIC Version 1.0 – 1991 Version 2.0 – 1992 Version 3.0 – 1993 Version 4.0 – 1995 Version 5.0 – 1997 Version 6.0 – 1998 Visual Basic.NET – 2002 (NOT BACKWARD COMPATIBLE WITH EARLIER VERSIONS) Visual Basic 2005 – November 2005 Visual Basic 2008 – November 2007 Visual Basic 2010 – April 2010 Visual Basic 2012 – Sept

2.2 V ISUAL B ASIC C ONTROLS Invoking Visual Basic Text Box Control Button Control Label Control List Box Control Name Property Help / Fonts / Auto Hide Positioning and Aligning Controls 15

V ISUAL B ASIC S TART P AGE 16

S TART A N EW P ROJECT 17

N EW P ROJECT D IALOG B OX 18

I NITIAL V ISUAL B ASIC S CREEN 19

T OOLBOX 20

T OOLBOX 21 Initiates an Action Displays output/make selections Get information (input) Display information (output) Shows what type of information is displayed in the textbox.

P LACING C ONTROL F ORMS 3 Ways to Place a Control from the Toolbox onto the Form Window Double-click Drag and Drop Click, Point, and Drag 22

T EXT B OX C ONTROL Used for input and output When used for output, ReadOnly property is set to True 23 Sizing handles Tasks button

P ROPERTIES W INDOW 24 Categorized view Alphabetical view Press F4 to display the Properties window for the selected control.

P ROPERTIES W INDOW 25 PropertiesSettings Selected control

S OME O FTEN U SED P ROPERTIES Text Autosize Font.Name Font.Size ForeColor BackColor ReadOnly 26

S ETTING P ROPERTIES Click on property name in left column. Enter its setting into right column by typing or selecting from options displayed via a button or ellipses. 27

F ORE C OLOR P ROPERTY 28 1.Click on ForeColor. 2.Click on button at right of settings box. 3.Click on Custom tab to obtain display shown. 4.Click on a color.

F ONT P ROPERTY 29 1.Click on Font in left column. 2.Click on ellipsis at right of settings box to obtain display shown, 3.Make selections.

B UTTON C ONTROL The caption on the button should indicate the effect of clicking on the button. Text property determines caption. 30

A DD AN " ACCESS KEY " 31

L ABEL C ONTROL Used to identify the contents of a text box/button/etc Text property specifies caption By default, label automatically resizes to accommodate caption on one line When the AutoSize property is set to False, label can be resized manually. Used primarily to obtain a multi- rowed label 32

L IST B OX C ONTROL Initially used to display several pieces of output. In Chapter 9 used to select from a list. 33

T HE N AME P ROPERTY Used by the programmer to refer to a control in code Setting for Name property near top of Properties window. Name must begin with a letter, be less than 215 characters long, and may include numbers and letters. Use appropriate 3- or 4- character naming prefix 34

C ONTROL N AME P REFIXES ControlPrefixExample buttonbtnbtnCompute labellbllblAddress text boxtxttxtAddress list boxlstlstOutput 35

R ENAMING THE F ORM Initial name is Form1 The Solution Explorer window lists a file named Form1.vb To rename the form, change the name of this file to newName.vb newName should begin with prefix frm 36

F ONTS Proportional width fonts take up less space for "I" than for "W" – like Microsoft Sans Serif Fixed-width fonts take up the same amount of space for each character – like Courier New Fixed-width fonts are used for tables 37

Demo the previous Label Button Colours Font Renaming Excellent walkthroughs in book 38

A UTO H IDE Hides Toolbox when not in use Vertical push pin icon indicates auto hide is disabled. Click the push pin to make it horizontal and enable auto hide. 39 Push pin

P OSITIONING C ONTROLS 40 Proximity line

A LIGNING C ONTROLS 41 Snap line

A LIGNING C ONTROLS 42 Snap line

T AB O RDER 43 Tab index The tab indices determine the order in which controls receive the focus during tabbing.

2.3 V ISUAL B ASIC E VENTS An Event Procedure Walkthrough Properties and Event Procedures of the Form The Header of an Event Procedure 44

E VENT 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 45

S AMPLE S TATEMENTS txtBox.ForeColor = Color.Red txtBox.Visible = True txtBox.Text = "Hello World" 46 General Form: controlName.property = setting What do the above mean?

S AMPLE F ORM 47 txtFirst txtSecond btnRed What events could there be?

F OCUS 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 48

E XAMPLES OF E VENTS btnShow.Click txtBox.TextChanged txtBox.Leave 49 General Form: controlName.event

E VENTS Take form, double click on textbox 50

E VENTS Enter area to write code for control 51

E XAMPLES OF E VENTS Select Event 52

3 STEPS IN CREATING A VB 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 53

C ODE E DITOR 54 Method Name box Class Name box Code Editor tab Form Designer tab

S TRUCTURE OF AN E VENT P ROCEDURE Private Sub objectName_event(...) Handles objectName.event statements End Sub (...) is filled automatically with (ByVal sender As System.Object, ByVal e As System.EventArgs) 55 Header

E VENT P ROCEDURE Double-click on a control or Use the Class Name and Method Name boxes. (We nearly always use the first method.) 56 Create an Outline for an Event Procedure; i.e. header and End Sub

S AMPLE F ORM 57 txtFirst txtSecond btnRed Double Click on txtFirst

C ODE FOR W ALKTHROUGH Public Class frmDemo Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged End Sub End Class 58

C ODE FOR W ALKTHROUGH Public Class frmDemo Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged txtFirst.ForeColor = Color.Blue End Sub End Class 59

I NTELLI S ENSE 60 Automatically pops up to give the programmer help. txtFirst.

C ODE E DITOR 61 Click tab to return to Form Designer

S AMPLE F ORM 62 txtFirst txtSecond btnRed Double-click on btnRed

C ODE FOR W ALKTHROUGH 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 63

C ODE FOR W ALKTHROUGH 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 64

E VENT P ROCEDURE Select txtFirst from Class Name box drop-down list Select Leave from Method Name box drop-down list 66

C ODE FOR W ALKTHROUGH Private Sub txtFirst_Leave(...) Handles txtFirst.Leave End Sub 67

C ODE FOR W ALKTHROUGH Private Sub txtFirst_Leave(...) Handles txtFirst.Leave txtFirst.ForeColor = Color.Black End Sub 68

H EADER OF E VENT P ROCEDURE Private Sub btnRed_Click(…) Handles btnRed.Click 69 Identifies event Name, can be changed. Private Sub Button_Press(…) Handles btnRed.Click

H ANDLING M ULTIPLE E VENTS 70 Private Sub Happening(...) Handles btnRed.Click,txtSecond.Leave txtFirst.ForeColor = Color.Red End Sub Event procedure can be invoked by two events.

A LTERING P ROPERTIES The following won't work: frmDemo.Text = "Demonstration" The form is referred to by the keyword M e. Me.Text = "Demonstration" 71

T EXT F ILE Holds data to be processed by programs Can be created, viewed, and managed by the Visual Basic IDE Create : Use “Add New Item” input dialog box View: Click on filename in Solution Explorer Manage: Use Solution Explorer like Windows Explorer 72

S AMPLE T EXT F ILE Mike Jones John Smith PAYROLL.TXT

S AMPLE T EXT F ILE Mike Jones John Smith name hourly wage hours worked PAYROLL.TXT

O UR T EXT F ILE C ONVENTION PAYROLL.TXT uses one item of data per line. That will be our convention in this book. 75

P OSSIBLE E VENTS 76 Events button Use Property Window to View all Possible Events for a Control

R UN AN E XISTING P ROGRAM 1. Click on Open Project in the File menu 2. Navigate to the program’s folder 3. Click on the program’s folder 4. Double-click on the file with extension.sln 5. In the Solution Explorer double-click on the file with extension.vb. (The Form Designer will appear.) 6. Press F5 to run the program 77

R UN P ROGRAM 78