Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.

Slides:



Advertisements
Similar presentations
Using Macros and Visual Basic for Applications (VBA) with Excel
Advertisements

Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
Microsoft Excel 2010 Chapter 7
An Introduction to Programming with C++ Fifth Edition Chapter 12 String Manipulation.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 9 Structures and Sequential Access Files.
Chapter 8: Manipulating Strings
MENUS AND THE MENU EDITOR Elements of a Menu Menu bar Menu title Separator bar Menu items.
Creating Menu. Objectives Create a menu system for a form –Create a menu –Create a menu titles –Create a menu items –Create a submenu –Modify menu –Edit.
Chapter 4: Working with Windows Types of Windows –Program Windows –Message Boxes –Dialog Boxes Elements of a Window –Window Panes –Scroll Bars –Menus –Tool.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Ten String Manipulation and Menus.
1.
Chapter 8: String Manipulation
Programming with Microsoft Visual Basic th Edition
 What are the different types of loops? ◦ Do….While  Performs statements within loop while a condition is true ◦ Do….Until  Performs statements within.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Typing Application Introducing Keyboard Events, Menus, Dialogs and the Dictionary.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
1 Working with Menus and Dialog Boxes. 2 Objectives You will be able to Create and edit menus for Windows Forms applications. Write code to handle menu.
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.
Word Lesson 2 Basic Editing
Copyright © 2010 Wolters Kluwer Health | Lippincott Williams & Wilkins Introduction to Windows Chapter 2.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Chapter 10: Structures and Sequential Access Files
Chapter Ten Structures and Sequential Access Files Programming with Microsoft Visual Basic th Edition.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Tutorial 11 Five windows included in the Visual Basic Startup Screen Main Form Toolbox Project Explorer (Project) Properties.
Key Applications Module Lesson 21 — Access Essentials
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
Microsoft Outlook 2010 Chapter 3 Managing Contacts and Personal Contact Information with Outlook.
Chapter 8: Manipulating Strings
Tutorial 91 Databases A database is an organized collection of related information stored in a file on a disk A database allows companies to store information.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
Chapter 12: String Manipulation Introduction to Programming with C++ Fourth Edition.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Shipping Hub Application.
Requirements – GUI TEAM B Undockable menus Drag away from edge to undock Menu undocks into a separate window.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Three Using Variables and Constants.
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.
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.
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.
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
Chapter 23 The String Section (String Manipulation) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Tutorial 8: Manipulating Strings1 Tutorial 8 Manipulating Strings.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
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.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
1 Word Lesson 2 Basic Editing Microsoft Office 2010 Introductory Pasewark & Pasewark.
Menu & Clipboard Menu Cut / Copy / Paste. Menus Created in the Menu Editor Can contain menu titles, menu items, separator bars, submenu titles, and submenu.
Tutorial 8: Manipulating Strings1 Tutorial 8 Manipulating Strings.
Microsoft Visual Basic 2008: Reloaded Third Edition
Microsoft Visual Basic 2005: Reloaded Second Edition
An Introduction to Computers and Visual Basic
An Introduction to Computers and Visual Basic
CIS16 Application Development and Programming using Visual Basic.net
String Manipulation and More Controls
An Introduction to Computers and Visual Basic
Microsoft Visual Basic 2005: Reloaded Second Edition
Microsoft Visual Basic 2005: Reloaded Second Edition
CIS16 Application Development and Programming using Visual Basic.net
Presentation transcript:

Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation

Working with Strings Applications often need to manipulate string data Two scenarios involving string manipulation –Determine first letter of an inventory part id –Search an address to find street name 2Programming with Microsoft Visual Basic 2008, Fourth Edition

Determining the Number of Characters in a String Length property: –Stores number of characters contained in string Syntax: string.Length Returns integer value 3Programming with Microsoft Visual Basic 2008, Fourth Edition

Removing Spaces from the Beginning and End of a String Trim method: –Removes spaces from both ends of string Computer makes temporary copy of string in memory, then performs trimming on copy –Original string is not changed –Modified copy is returned to program 4Programming with Microsoft Visual Basic 2008, Fourth Edition

Replacing Characters in a String Replace method: –Replaces one sequence of characters with another Example: Replace area code “800” with “877” Must specify both sequence of characters in string to be replaced, and replacement characters to be used Computer makes temporary copy of string and replaces specified characters in copy Returns string that includes replaced characters 5Programming with Microsoft Visual Basic 2008, Fourth Edition

Replacing Characters in a String (continued) 6Programming with Microsoft Visual Basic 2008, Fourth Edition Figure 8-6: Syntax, purpose, and examples of the Replace method

The Mid Statement Mid statement: –Replaces set of characters with another string Must specify: –targetString: String targeted for character replacement –replacementString: Contains replacement characters to be used –start: Position of first character of targetString where replacement should take place –count: Number of characters to replace in targetString 7Programming with Microsoft Visual Basic 2008, Fourth Edition

The Mid Statement (continued) 8Programming with Microsoft Visual Basic 2008, Fourth Edition Figure 8-7: Syntax, purpose, and examples of the Mid statement

Inserting Characters in a String PadLeft method: –Inserts padded characters at start of string –Right-aligns characters within string PadRight method: –Inserts padded characters at end of string –Left-aligns characters within string Must specify character to pad with, and desired final total length of target string –If no character is specified, space is used 9Programming with Microsoft Visual Basic 2008, Fourth Edition

Insert Method Insert method: –Inserts characters anywhere within string Examples: –Insert middle initial within employee name –Insert parentheses around area code in phone number Must specify position (index) where new characters will be inserted 10Programming with Microsoft Visual Basic 2008, Fourth Edition

Insert Method (continued) 11Programming with Microsoft Visual Basic 2008, Fourth Edition Figure 8-11: Syntax, purpose, and example of the Insert method

Accessing Characters Contained in a String Substring method: –Used to access any number of characters in string –Returns string with specified number of characters Must specify index of first character to access in string, and number of characters to retrieve –If number of characters is not specified, all characters from start position to the end of string are returned 12Programming with Microsoft Visual Basic 2008, Fourth Edition

Accessing Characters Contained in a String (continued) 13Programming with Microsoft Visual Basic 2008, Fourth Edition Figure 8-18: Syntax, purpose, and examples of the Substring methodc

Using Pattern-Matching to Compare Strings Like operator: –Allows use of pattern-matching characters to determine whether one string is equal to another Must specify string to be examined and pattern to be matched –Pattern can contain pattern-matching characters Returns Boolean value –Returns True if match is made, False otherwise 14Programming with Microsoft Visual Basic 2008, Fourth Edition

Using Pattern-Matching to Compare Strings (continued) 15Programming with Microsoft Visual Basic 2008, Fourth Edition Figure 8-21: Syntax, purpose, and examples of the Like operator

Adding a Menu to a Form MenuStrip control: Used to include one or more menus in application Menu title: Appears on menu bar at top of form Menu items can include: –Commands, submenu items, or separator bars Clicking command on menu executes it Clicking submenu item opens additional menu Separator bars provides visual grouping 16Programming with Microsoft Visual Basic 2008, Fourth Edition

Adding a Menu to a Form (continued) 17Programming with Microsoft Visual Basic 2008, Fourth Edition Figure 8-24: Location of menu elements

Adding a Menu to a Form (continued) 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: –Ellipsis (…) after item caption indicates dialog box will display for user input –File menu should be first item on menu bar –Cut, Copy, Paste should appear on Edit menu 18Programming with Microsoft Visual Basic 2008, Fourth Edition

Assigning Shortcut Keys to Menu Items Shortcut keys: –Appear to right of menu item –Allow you to select item without opening menu Example: Ctrl+S executes Save in MS Word Assign shortcut keys to commonly used menu items –Follow Windows standard conventions Shortcut keys can be used when menu is closed 19Programming with Microsoft Visual Basic 2008, Fourth Edition

Assigning Shortcut Keys to Menu Items (continued) 20Programming with Microsoft Visual Basic 2008, Fourth Edition Figure 8-29: Shortcut key specified in the ShortcutKeys box

Assigning Shortcut Keys to Menu Items (continued) 21Programming with Microsoft Visual Basic 2008, Fourth Edition Figure 8-30: Location of the shortcut key on the menu