Saving and Loading Simple Text Files A sequential file stores characters one after the other like songs on a cassette tape. New characters are added to.

Slides:



Advertisements
Similar presentations
What Was I Thinking??. Key Terms 1. Control 1. Control 2. Design Mode 2. Design Mode 3. Event 3. Event 4. Form 4. Form 5. Interface 5. Interface 6. Properties.
Advertisements

ITEC 1001 Tutorial 1 Using Common Features of Microsoft Office 2003.
Using Macros and Visual Basic for Applications (VBA) with Excel
Tutorial 12: Enhancing Excel with Visual Basic for Applications
The Web Warrior Guide to Web Design Technologies
© by Pearson Education, Inc. All Rights Reserved.
Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
Automating Tasks With Macros
Using Visual Basic 6.0 to Create Web-Based Database Applications
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
Macromedia Dreamweaver 4 Advanced Level Course. Add Rollovers Rollovers or mouseovers are possibly the most popular effects used in designing Web pages.
XP 1 Using Common Features of Microsoft Office 2003 Rod Rodrigues.
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.
XP Using Common Features of Microsoft Office Tutorial 1.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Excel Lesson 14 Creating and Using Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Word Lesson 16 Working with Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
1 Lesson 6 — Database Programming Microsoft Visual Basic.NET, Introduction to Programming.
© Cheltenham Computer Training 2001 Macromedia Dreamweaver 4 - Slide No 1 Macromedia Dreamweaver 4 Advanced Level Course.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Using Visual Basic 6.0 to Create Web-Based Database Applications
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
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures.
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
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.
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Visual Basic.NET BASICS Lesson 3 Events and Code.
Fundamentals of GUI Programming. Objectives: At the end of the session, you should be able to: describe the guidelines that are used for creating user-friendly.
Introduction to Programming with RAPTOR
Numbers continued The Integer Data Type Multiple Declarations Parentheses Three Types of Errors.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
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.
Written module activity, Page 16 1.We refer to the physical parts of a computer that we can touch and see as hardware. Examples include the mouse, the.
Tutorial 81 Field, Record, Data File Field - a single item of information about a person, place, or thing Record - a group of related fields that contain.
MICROSOFT OFFICE APPLICATIONS Computer Basics 1.6.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
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.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Key Applications Module Lesson 12 — Word Essentials Computer Literacy BASICS.
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.
Excel Tutorial 8 Developing an Excel Application
Presentation transcript:

Saving and Loading Simple Text Files A sequential file stores characters one after the other like songs on a cassette tape. New characters are added to the end of the file. When a file is opened for reading, the characters are read one by one from the beginning of the file to its end. A random access file stores information in pieces called records. Each record is exactly the same length. If a record is 50 bytes long, the fourth record of the file is easily found by jumping over 150 bytes, the length of three records combined.

System.IO The first step in reading a simple text file and copying its contents into the text box on the form is to add an Imports System.IO statement to the top of the form class definition. This statement makes the Input/Output classes available to the project.

Step-by-Step 5.8 Sub LoadFile() Dim f As File = New File(PathName) Dim fs As StreamReader fs = f.OpenText() txtContent.Text = fs.ReadToEnd fs.close() End Sub

Did You Know? You can get a device for your computer that acts like a remote keyboard. It looks like a simple laptop with a small LCD screen that displays several lines of text. While it doesn't run any programs and cannot handle graphics, it has enough memory to store many pages of text. It allows you to key and save the information to upload to your computer at a later time. When you are ready to transfer the data to your computer, it communicates with your computer through an infrared link connected to your keyboard cable. You open a word processor on your computer and spill the contents of your portable computer through the infrared link to the keyboard cable as if you were keying the text at that moment.

Step-by-Step 5.8 'MessageBox.Show("Call the Open File dialog box.") With OpenFileDialog1.DefaultExt = "txt".InitialDirectory = "c:\My Documents".Filter = "Text files | *.txt".ShowDialog() PathName =.FileName End With MenuItem3.Text = MenuItem2.Text MenuItem2.text = PathName LoadFile()

Step-by-Step 5.8 'MessageBox.Show("Call the Save File dialog box.") With SaveFileDialog1.InitialDirectory = "c:\My Documents".Filter = "Text files | *.txt".ShowDialog() PathName =.FileName End With

Step-by-Step 5.8 Dim f As File = New File(PathName) Dim fs As StreamWriter Dim strContent As String = txtContent.Text fs = f.CreateText fs.WriteLine(strContent) fs.Close()

Step-by-Step 5.8 'MessageBox.Show("Call the Font dialog box.") With FontDialog1.ShowDialog() txtContent.Font =.Font End With

Step-by-Step 5.8 'MessageBox.Show("Create a new document.") txtContent.ResetText() PathName = MenuItem2.Text Loadfile() PathName = MenuItem3.Text Loadfile()

Did You Know? In the earliest forms of BASIC, every assignment statement had to be preceded by the word Let. This was how the BASIC interpreter identified an assignment statement.

Important Comments at the beginning of the routine document what the routine does and what other routines call it. Comments start with a single quote and can appear anywhere on the line. Despite the fact that Bill Gates claims to know sections of the code from his first version of BASIC by heart, most programmers forget the code they have written shortly after it is written. Internal documentation is very important.

Summary The MessageBox.Show statement is used to communicate a short message to the user. The MessageBox.Show function is used when the response from the user can be limited to a button click. The syntax for MessageBox.Show function is variable = MessageBox.Show(text [, caption ] [, buttons ] [, icon ] [defaultButton ] [, options ] ) Visual Basic provides many constants to simplify supplying parameter values to functions and procedures. The constants are stored as properties of the object to which they apply. The InputBox function gathers up to 255 characters from the user. The syntax for the InputBox function is variable = InputBox (prompt [, title] [, default] [, xpos] [, ypos])

Summary A run-time error occurs when a program cannot perform a task that it expects to be able to perform. The Val( ) function is one of several functions used to convert the string entered with an InputBox function to a value. A pop-up context menu appears when the user right-clicks the mouse button. It provides commonly used commands in a convenient package to facilitate user interaction with the program. There may be several context menus in an application, each linked to a different control. Every event procedure passes two parameters. The Sender parameter identifies the object in which the event was initiated. The e parameter contains information about the event raised. It is tailored to each event and contains just the information relevant to the event.

Summary The ImageList control is used to store images for the Toolbar control. Once the image list is loaded with images, it can be attached to a toolbar where the images are used to label buttons. The images occupy the Images collection of the ImageList control. The toolbar contains buttons labeled with images from the ImageList control that provide commonly used commands to the user. Often the toolbar buttons mirror menu items. The buttons of the toolbar are contained in the toolbar's Buttons collection. The Visible property of a menu item is used to enable or disable the display of the menu item. Always supply ToolTip text for each button of a toolbar.

Summary A toolbar button may have a drop-down list attached. The list may be preloaded with options at design time or items may be added at run time. All buttons share the same event procedure, ToolBar1_ButtonClick. Individual buttons are passed to the event procedure in the e parameter. Buttons are differentiated by their Text property. The Resize event of a form fires whenever the form is resized. This is the place to put code that resizes or repositions controls on the form. A sequential file stores characters one after the other like songs on a cassette tape. New characters are added to the end of the file.

Summary Dialog controls are used to provide a project with a number of common Windows dialog boxes. These are dialog boxes with which any Windows user is familiar: Open, Save, Font, Printer, and Color. Text files are easily created and accessed through StreamReader and StreamWriter classes used in conjunction with the File class. The With statement lets you go "one layer" into a control. This eliminates the need to retype the name of the control each time its properties or methods are accessed.