CIS16 Application Development and Programming using Visual Basic.net

Slides:



Advertisements
Similar presentations
Chapter 11: Classes and Objects
Advertisements

Chapter 11 Data Files Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
VBA Modules, Functions, Variables, and Constants
Chapter 9: Sequential Access Files and Printing
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 9 Structures and Sequential Access Files.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Ten String Manipulation and Menus.
Chapter 8: String Manipulation
Programming with Microsoft Visual Basic th Edition
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2005: Reloaded Second Edition
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Using Arrays and File Handling
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
Teacher: Ms. Olifer MICROSOFT VISUAL STUDIO 2010: PROPERTIES OF WINDOWS FORM OBJECT.
Tutorial 61 List Box Control Can be used to display a set of choices from which the user can select only one You also can create multi-selection list boxes.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter 10: Structures and Sequential Access Files
Chapter Ten Structures and Sequential Access Files Programming with Microsoft Visual Basic th Edition.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
11-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Chapter Ten Structures and Sequential Access Files Programming with Microsoft Visual Basic th Edition.
Chapter 10 Sequential Files and Structures. Class 10: Sequential Files Work with different types of sequential files Read sequential files based on the.
File I/O What We’ll Cover –Visual Basic Techniques for Text Files –.NET Techniques for Text Files What We’ll Not Cover –Binary File I/O –XML File I/O.
Chapter 8: Manipulating Strings
Tutorial 9: Sequential Access Files and Printing1 Tutorial 9 Sequential Access Files and Printing.
An Introduction to Programming with C++ Sixth Edition Chapter 14 Sequential Access Files.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
5 1 Data Files CGI/Perl Programming By Diane Zak.
1.
Copyright © 2012 Pearson Education, Inc. Chapter 5 Loops, File, and Random Numbers.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
Programming with Microsoft Visual Basic th Edition
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Ten Structures and Sequential Access Files.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
BACS 287 File-Based Programming. BACS 287 Data Hierarchy  Database - Collection of files, relationships, integrity information, etc  Files - All records.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 9 Structures and Sequential Access Files.
Tutorial 8: Manipulating Strings1 Tutorial 8 Manipulating Strings.
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 11 Data Files.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
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.
Menu & Clipboard Menu Cut / Copy / Paste. Menus Created in the Menu Editor Can contain menu titles, menu items, separator bars, submenu titles, and submenu.
1 Displaying Dialog Boxes Kashef Mughal. 2 Midterm Stats Here we go  Average was  Low was 116  High was 184  Mid Quarter Grade - check any.
Chapter 8 Multiple Forms, Modules, and Menus. Introduction This chapter demonstrates how to: – Add multiple forms to a project – Create a module to hold.
Tutorial 8: Manipulating Strings1 Tutorial 8 Manipulating Strings.
Chapter 4: Do-It-Yourself Designing (Designing Interfaces)
Programming Right from the Start with Visual Basic .NET 1/e
Chapter 14: Sequential Access Files
Excel Tutorial 8 Developing an Excel Application
Unit 2 Technology Systems
Microsoft Visual Basic 2005: Reloaded Second Edition
Multiple Classes and Inheritance
Files.
Using Procedures and Exception Handling
CIS16 Application Development Programming with Visual Basic
CIS16 Application Development and Programming using Visual Basic.net
Chapter 3.5 Input and Output
CIS16 Application Development and Programming using Visual Basic.net
Tutorial 9 Sequential Access Files and Printing
CIS16 Application Development and Programming using Visual Basic.net
Chapter 11 Saving Data and Objects In Files
Presentation transcript:

CIS16 Application Development and Programming using Visual Basic.net Chapter Nine Structures and Sequential Files

STRUCTURES

Structures Structures are objects you can create to hold data or code Used when you need to pass a group of related items to a procedure for further processing, or to store related items in an Array Structure statement is defined in the Declarations section of the class –NOT inside a SUB

Structures Like an Array Like a record in a table in that related items are grouped into list Like a record in a table in that related items are grouped together with a unique identifier

Structures Inside the structure are the items (members) Items can have different data types, and can be variables, constants or procedures Use Pascal case when defining items

Structures (cont'd.) Variables Referred to as Member Variables Each member variable’s definition contains the keyword Public followed by the variable’s name and data type

Structures (cont'd.) Structures can be instantiated into structure variable objects structure variable is an object declared using a structure as its data type rather than a true data type If declaring a structure variable object in a procedure Use the Dim keyword If declaring a structure variable object in a Class use the Private keyword

Structures (cont'd.) Instantiating

Structures (cont'd.) Populating

Creating an Array of Structure Variables

Creating an Array of Structure Variables a structure variable can be stored in an array, even when its members have different data types

Sequential Access Files

Reading and Writing Records Sequential files can be used to store records and fields A field is a single item of information about a person, place, or thing A record is a group of related fields that contain all of the necessary data about a specific person, place, or thing When writing records to a sequential access file, programmers typically write each record on a separate line in the file They use a special character, called a delimiter character, to separate each field Commonly used delimiter characters include the comma and the number (or hash) sign (#)

Sequential Access Files Input files An application uses the data in these files as input Output files Files that store the output produced by an application Sequential access files Composed of lines of text that are both read and written sequentially (in consecutive order), one line at a time Also called text files

Sequential Access File Objects StreamWriter object Allows you to write a stream of characters to a sequential access file StreamReader object Used to read data streams from a sequential access file

STREAMWRITER Methods: CreateText() AppendText() Write() WriteLine() Close() STREAMWRITER

StreamWriter Used to write data to a sequential access file StreamWriter object Allows you to write a stream of characters to a sequential access file Define Writer as procedure/class level object

StreamWriter Used to write data to a sequential access file CreateText method Used to open a sequential access file for output (creates a new, empty file) Unless otherwise specified, gets created in the bin/Debug folder

StreamWriter Used to write data to a sequential access file Write method When using the Write method, the next character written to the file will appear immediately after the last letter in the string WriteLine method When using the WriteLine method, the next character written to the file will appear on the line immediately below the string

StreamWriter Used to write data to a sequential access file AppendText method Used to open a sequential access file for append(new data is written after existing data)

StreamWriter Used to write data to a sequential access file Use the Close method to close an output sequential access file Ensures that the data is saved and it makes the file available for use elsewhere in the application

Writing Records (cont'd.) When writing records, separate fields using a delimiter

Methods: OpenText() Peek() ReadLine() Close() STREAMREADER

StreamReader Used to read data from a sequential access file Define StreamReader as a procedure/class level object(s)

StreamReader Used to read data from a sequential access file Before using it, use EXISTS method to make sure it actually was created Exists method Returns the Boolean value True if the file exists; otherwise, it returns the Boolean value False

StreamReader Used to read data from a sequential access file The OpenText method opens a sequential access file for input, and creates an instance of the Reader Unless otherwise specified, looks for it in the bin/Debug folder

StreamReader Used to read data from a sequential access file Peek method “Peeks” into the file to determine whether it contains another line to read -1 indicates EOF

StreamReader Used to read data from a sequential access file The ReadLine method reads the file’s contents, one line (characters followed by the newline character) at a time

StreamReader Used to read data from a sequential access file The Close method closes the file

Reading Records To Read records with multiple fields, use Split function Separates fields in record, creating a String array Specify delimiter, and data type conversion, if necessary

Adding a Menu to a Form Menu strip control Used to include one or more menus on a form A menu title appears on the menu bar at the top of the form Menu items can include: Commands Submenu items Separator bars Clicking a command on a menu executes it Clicking a submenu item opens an additional menu Separator bars provide visual grouping

Adding a Menu to a Form (cont.) Menu title captions should be one word only Menu item captions can be from one to three words Assign unique access keys to menu titles and items Follow Windows menu standards: Use book title capitalization for menu item captions An ellipsis (…) after an item caption indicates a menu item requires more information The FILE menu should be the first item on the menu bar Cut, Copy, and Paste should appear on the EDIT menu

Adding a Menu to a Form Menu Strip Control To include one or more menus on a Form The shortcut keys appear to the right of a menu item and allow the user to select the item without opening the menu

Adding a Menu to a Form (cont'd.) Figure 10-9: FILE menu

Adding a Menu to a Form (cont.) Assigning Shortcut Keys to Menu Items Shortcut keys Appear to the right of a menu item Allow the user to select an item without opening a menu Example: Ctrl+X and Ctrl+V Cut and paste commands Assign shortcut keys to commonly used menu items Follow Windows standard conventions Shortcut keys can be used when a menu is closed

Adding a Menu to a Form (cont.) Assigning Shortcut Keys to Menu Items (cont.) Figure 8-28 Location of the shortcut keys on the menu Figure 8-27 Shortcut keys specified in the ShortcutKeys box

Adding a Menu to a Form (cont.) Coding the Exit Menu Item How to end the Pizza Game application: The user clicks the Exit item on the FILE menu The Exit item’s Click event procedure calls Me.Close() Coding the txtLetter Control’s KeyPress Event Figure 8-29 txtLetter_KeyPress procedure