REVIEW OF CHAPTER 1 1

Similar documents
Chapter 2 Visual Basic, Controls, and Events. 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual Basic Events

Introducing Visual Basic

Chapter 3. Fundamentals of Programming in Visual Basic

Introducing Visual Basic

HOW TO DEVELOP A VB APPLICATION

Program and Graphical User Interface Design

Using Visual Basic Studio 2008

Computer Science 110. NOTES: module 8

Skill Area 336 Explain Essential Programming Concept. Programming Language 2 (PL2)

Dive Into Visual C# 2008 Express

Departme and. Computer. CS Intro to. Science with. Objectives: The main. for a problem. of Programming. Syntax Set of rules Similar to.

Introduction to the Visual Studio.NET Integrated Development Environment IDE. CSC 211 Intermediate Programming

GUI Design and Event- Driven Programming

COPYRIGHTED MATERIAL. Visual Basic: The Language. Part 1

2 USING VB.NET TO CREATE A FIRST SOLUTION

INTRODUCTION TO VISUAL BASIC 2010

Welcome Application. Introducing the Visual Studio.NET IDE. Objectives. Outline

LESSON A. The Splash Screen Application

Dive Into Visual C# 2010 Express

STUDENT SOLUTIONS MANUAL

Disclaimer. Trademarks. Liability

Introductionto the Visual Basic Express 2008 IDE

Tutorial 03 understanding controls : buttons, text boxes

LESSON B. The Toolbox Window

CIS 3260 Intro. to Programming with C#

Visual Basic.NET. 1. Which language is not a true object-oriented programming language?

Text box. Command button. 1. Click the tool for the control you choose to draw in this case, the text box.

Getting started 7. Setting properties 23

Review. October 20, 2006

Microsoft Visual Basic 2005: Reloaded

Wyo VB Lecture Notes - Objects, Methods, & Properties

Visual Basic 2008 The programming part

Tutorial 2 - Welcome Application Introducing, the Visual Studio.NET IDE

CST242 Windows Forms with C# Page 1

Lecture 1 Introduction Phil Smith

SYLLABUS B.Com (Computer) VI SEM Subject Visual Basic Unit I

Chapter 2. Creating Applications with Visual Basic Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of

Getting started 7. Setting properties 23

Chapter 2 Exploration of a Visual Basic.Net Application

HOUR 4 Understanding Events

Getting Started with Visual Basic.NET

FIT 100. Lab 8: Writing and Running Your First Visual Basic Program Spring 2002

Full file at

Introduction to the Visual Studio 2005

Altering Layouts. Changing Font. Universal Engraving Machine. Chapter 18 Altering Layouts

Let s Make a Front Panel using FrontCAD

A Complete Tutorial for Beginners LIEW VOON KIONG

FOR 240 Homework Assignment 4 Using DBGridView and Other VB Controls to Manipulate Database Introduction to Computing in Natural Resources

IT3101 -Rapid Application Development Second Year- First Semester. Practical 01. Visual Basic.NET Environment.

1: Getting Started with Microsoft Excel

Exploring Microsoft Office Word 2007

The Filter Property Selecting a File The Save Menu The SaveFileDialog Control The Edit Menu The Copy Menu...

Display Systems International Software Demo Instructions

Chapter 1: A First Program Using C#

Visual C# Program: Simple Game 3

Full file at Programming in Visual Basic 2010

Chapter. Web Applications

2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction

Address Bar. Application. The space provided on a web browser that shows the addresses of websites.

Introduction. Getting Started with Visual Basic Steps:-

Adobe InDesign Notes. Adobe InDesign CS3

PA Payroll Exercise for Intermediate Excel

Corel Ventura 8 Introduction

17. Introduction to Visual Basic Programming

Sema Foundation ICT Department. Lesson - 18

Multimedia web page Board

Visit for more.

1 Dept: CE.NET Programming ( ) Prof. Akash N. Siddhpura. Working with Form: properties, methods and events

MockupScreens - User Guide

Programming in C# Project 1:

The first program we write will display a picture on a Windows screen, with buttons to make the picture appear and disappear.

Adobe InDesign CS6 Tutorial

ekaizen Lessons Table of Contents 1. ebook Basics 1 2. Create a new ebook Make Changes to the ebook Populate the ebook 41

Part I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations

TRAINING GUIDE FOR OPC SYSTEMS.NET. Simple steps to successful development and deployment. Step by Step Guide

Visual Basic. murach s. (Chapter 2) TRAINING & REFERENCE. Mike Murach & Associates, Inc.

Chapter 1. Introduction to Programming and Visual Basic Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

Upgrading Applications

COPYRIGHTED MATERIAL. Welcome to Visual Basic 2005

Customization Manager

Lab 4: Adding a Windows User-Interface

1Welcome to Visual Basic 2010

To get started with Visual Basic 2005, I recommend that you jump right in

Developing Student Programming and Problem-Solving Skills With Visual Basic

Keeping Track, Menus. CSC 330 Object-Oriented Programming 1

ICDL & OOo BASE. Module Five. Databases

First Visual Basic Lab Paycheck-V1.0

Getting Started With the CCPilot VI and QuiC

Creating Interactive Workbooks Using MS Excel Sarah Mabrouk, Framingham State College

Using event-driven programming Installing Visual Basic 2015 Touring the Visual Basic 2015 integrated development environment

MICROSOFT WORD 2010 BASICS

Microsoft Word 2007 Tutorial CIS*1000*DE

Drill Table. Summary. Modified by Phil Loughhead on 16-Jun Parent page: PCB Dialogs

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals

Navigate to Success: A Guide to Microsoft Word 2016 For History Majors

Tutor Handbook for WebCT

Windows Application Development Tutorial for ASNA Visual RPG 8.0 for Microsoft Visual Studio.NET 2005

SETTING UP A. chapter

Chapter 2 Visual Basic, Controls, and Events

Transcription:

1 REVIEW OF CHAPTER 1

Trouble installing/accessing Visual Studio? 2

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) REVIEW Software: programs that run on a computer 3

REVIEW 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, )

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

6 CHAPTER 2 Visual Basic, Controls, and Events

VISUAL BASIC, CONTROLS, AND EVENTS 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual Basic Events 7

VISUAL BASIC 2010 Before VB, a window required hundreds of lines of code Now Fewer instructions Consistent Less time User-friendly 8

VISUAL BASIC 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

BEFORE VB 10

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

HOW TO DEVELOP A VB APPLICATION 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

WHAT 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

DIFFERENT VERSIONS OF VISUAL BASIC 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 2012 14

2.2 VISUAL BASIC CONTROLS Invoking Visual Basic Text Box Control Button Control Label Control List Box Control Name Property Help / Fonts / Auto Hide Positioning and Aligning Controls 15

VISUAL BASIC START PAGE 16

START A NEW PROJECT 17

NEW PROJECT DIALOG BOX 18

INITIAL VISUAL BASIC SCREEN 19

TOOLBOX 20

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

PLACING CONTROL FORMS 3 Ways to Place a Control from the Toolbox onto the Form Window Double-click Drag and Drop Click, Point, and Drag 22

Used for input and output TEXT BOX CONTROL When used for output, ReadOnly property is set to True Tasks button Sizing handles 23

PROPERTIES WINDOW Press F4 to display the Properties window for the selected control. Categorized view Alphabetical view 24

PROPERTIES WINDOW Selected control Properties Settings 25

SOME OFTEN USED PROPERTIES Text Autosize Font.Name Font.Size ForeColor BackColor ReadOnly 26

SETTING PROPERTIES 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

FORECOLOR PROPERTY 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. 28

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

BUTTON CONTROL The caption on the button should indicate the effect of clicking on the button. Text property determines caption. 30

ADD AN "ACCESS KEY" 31

LABEL CONTROL 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 multirowed label 32

LIST BOX CONTROL Initially used to display several pieces of output. In Chapter 9 used to select from a list. 33

THE NAME PROPERTY 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

CONTROL NAME PREFIXES Control Prefix Example button btn btncompute label lbl lbladdress text box txt txtaddress list box lst lstoutput 35

RENAMING THE FORM 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

Proportional width fonts take up less space for "I" than for "W" like Microsoft Sans Serif FONTS 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

AUTO HIDE 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. Push pin 39

POSITIONING CONTROLS Proximity line 40

ALIGNING CONTROLS Snap line 41

ALIGNING CONTROLS Snap line 42

TAB ORDER Tab index The tab indices determine the order in which controls receive the focus during tabbing. 43

2.3 VISUAL BASIC EVENTS An Event Procedure Walkthrough Properties and Event Procedures of the Form The Header of an Event Procedure 44

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

SAMPLE STATEMENTS General Form: controlname.property = setting txtbox.forecolor = Color.Red txtbox.visible = True txtbox.text = "Hello World" What do the above mean? 46

SAMPLE FORM txtfirst txtsecond btnred What events could there be? 47

When you click on a text box, a cursor appears in the text box, and you can type into the text box FOCUS 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

EXAMPLES OF EVENTS General Form: controlname.event btnshow.click txtbox.textchanged txtbox.leave 49

EVENTS Take form, double click on textbox 50

EVENTS Enter area to write code for control 51

EXAMPLES OF EVENTS 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

CODE EDITOR Code Editor tab Form Designer tab Class Name box Method Name box 54

STRUCTURE OF AN EVENT PROCEDURE Header 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

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

SAMPLE FORM txtfirst txtsecond btnred Double Click on txtfirst 57

CODE FOR WALKTHROUGH Public Class frmdemo Private Sub txtfirst_textchanged(...) Handles txtfirst.textchanged End Sub End Class 58

CODE FOR WALKTHROUGH Public Class frmdemo Private Sub txtfirst_textchanged(...) Handles txtfirst.textchanged txtfirst.forecolor = Color.Blue End Sub End Class 59

INTELLISENSE Automatically pops up to give the programmer help. txtfirst. 60

CODE EDITOR Click tab to return to Form Designer 61

SAMPLE FORM txtfirst txtsecond btnred Double-click on btnred 62

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 63

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 64

EVENT PROCEDURE Select txtfirst from Class Name box drop-down list Select Leave from Method Name box drop-down list 66

CODE FOR WALKTHROUGH Private Sub txtfirst_leave(...) Handles txtfirst.leave End Sub 67

CODE FOR WALKTHROUGH Private Sub txtfirst_leave(...) Handles txtfirst.leave txtfirst.forecolor = Color.Black End Sub 68

HEADER OF EVENT PROCEDURE Private Sub btnred_click( ) Handles btnred.click Name, can be changed. Identifies event Private Sub Button_Press( ) Handles btnred.click 69

HANDLING MULTIPLE EVENTS Event procedure can be invoked by two events. Private Sub Happening(...) Handles btnred.click,txtsecond.leave txtfirst.forecolor = Color.Red End Sub 70

ALTERING PROPERTIES The following won't work: frmdemo.text = "Demonstration" The form is referred to by the keyword Me. Me.Text = "Demonstration" 71

TEXT FILE 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

SAMPLE TEXT FILE Mike Jones 9.35 35 John Smith 10.75 33 PAYROLL.TXT 73

SAMPLE TEXT FILE name hourly wage hours worked Mike Jones 9.35 35 John Smith 10.75 33 PAYROLL.TXT 74

OUR TEXT FILE CONVENTION PAYROLL.TXT uses one item of data per line. That will be our convention in this book. 75

POSSIBLE EVENTS Use Property Window to View all Possible Events for a Control Events button 76

RUN AN EXISTING PROGRAM 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

RUN PROGRAM 78