Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.

Slides:



Advertisements
Similar presentations
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 9 Strings.
Advertisements

1 Strings and Text I/O. 2 Motivations Often you encounter the problems that involve string processing and file input and output. Suppose you need to write.
© 2010 Delmar, Cengage Learning Chapter 9: Using ActionScript.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
An Introduction to Programming with C++ Fifth Edition Chapter 12 String Manipulation.
Chapter 8: Manipulating Strings
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
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
Lesson 3 – Regular Expressions Sandeepa Harshanganie Kannangara MBCS | B.Sc. (special) in MIT.
Chapter 9 Creating Formulas that Manipulate Text Microsoft Office Excel 2003.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL.
CHƯƠNG 3 Finding, Filtering, and Formatting Data.
ASP.NET Programming with C# and SQL Server First Edition Chapter 5 Manipulating Strings with C#
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
Chapter 10: Structures and Sequential Access Files
Chapter Ten Structures and Sequential Access Files Programming with Microsoft Visual Basic th Edition.
Tutorial 11 Five windows included in the Visual Basic Startup Screen Main Form Toolbox Project Explorer (Project) Properties.
Chapter Ten Structures and Sequential Access Files Programming with Microsoft Visual Basic th Edition.
Fundamentals of Python: First Programs
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Oracle 11g: SQL Chapter 10 Selected Single-Row Functions.
String Manipulation. Strings have their own properties and methods, just like a textbox or label or form does.
Chapter 8: Manipulating Strings
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Screen Scraping Application Introducing String Processing.
Chapter 12: String Manipulation Introduction to Programming with C++ Fourth Edition.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
When you read a sentence, your mind breaks it into tokens—individual words and punctuation marks that convey meaning. Compilers also perform tokenization.
1.
CSCI 3327 Visual Basic Chapter 12: Strings, Characters and Regular Expressions UTPA – Fall 2011.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
C++ String Class nalhareqi©2012. string u The string is any sequence of characters u To use strings, you need to include the header u The string is one.
1 Chapter 3 – Examples The examples from chapter 3, combining the data types, variables, expressions, assignments, functions and methods with Windows controls.
C++ for Engineers and Scientists Second Edition Chapter 7 Completing the Basics.
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.
String Manipulation 10/21/2015 Lect#6 GC Strings have their own properties and methods, just like a textbox or label or form does. 10/21/2015 Lect#6.
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
Chapter 3 I Need a Tour Guide (Introduction to Visual Basic 2010) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Decisions with Select Case and Strings Chapter 4 Part 2.
1 CSE 2337 Chapter 7 Organizing Data. 2 Overview Import unstructured data Concatenation Parse Create Excel Lists.
8 1 String Manipulation CGI/Perl Programming By Diane Zak.
Chapter 23 The String Section (String Manipulation) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 11 So Many Paths … So Little Time.
Tutorial 8: Manipulating Strings1 Tutorial 8 Manipulating Strings.
Strings, Characters, and Regular Expressions Session 10 Mata kuliah: M0874 – Programming II Tahun: 2010.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 19 A Ray of Sunshine.
Lesson 4 String Manipulation. Lesson 4 In many applications you will need to do some kind of manipulation or parsing of strings, whether you are Attempting.
Lecture Set 6 The String and DateTime Data Types Part B – Characters and Strings String Properties and Methods.
Tutorial 8: Manipulating Strings1 Tutorial 8 Manipulating Strings.
Microsoft Visual Basic 2008: Reloaded Third Edition
Computer Programming ||
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL
Strings, StringBuilder, and Character
Vi Editor.
Microsoft Visual Basic 2005 BASICS
SQL Text Manipulation Farrokh Alemi, Ph.D.
CIS16 Application Development and Programming using Visual Basic.net
Microsoft Visual Basic 2005 BASICS
String Manipulation and More Controls
Fundamentals of Python: First Programs
Microsoft Visual Basic 2005: Reloaded Second Edition
Microsoft Visual Basic 2005: Reloaded Second Edition
String Processing 1 MIS 3406 Department of MIS Fox School of Business
Introduction to Computer Science
Presentation transcript:

Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section

Clearly Visual Basic: Programming with Visual Basic 2008 Objectives Determine the number of characters in a string Remove spaces from the beginning and end of a string Replace characters in a string Insert characters in a string Search a string Access characters in a string Compare strings using pattern-matching 2

Clearly Visual Basic: Programming with Visual Basic 2008 Working with Strings Many times: –An application will need to manipulate (process) string data in some way The first string manipulation technique in this chapter –Shows you how to determine the number of characters in a string 3

Clearly Visual Basic: Programming with Visual Basic 2008 How Many Characters Are There? If an application expects the user to enter a seven- digit phone number: –Application’s code should verify that the user entered the required number of characters Number of characters contained in a string –Stored in the string’s Length property Value stored in the property is an integer 4

Clearly Visual Basic: Programming with Visual Basic 20085

Get Rid of Those Spaces Trim method –Used to remove (trim) any spaces from both the beginning and end of a string –Does not remove any characters from the original string –Returns a string that excludes any leading or trailing spaces 6

Clearly Visual Basic: Programming with Visual Basic 20087

The Product ID Application Displays (in a label control): –A listing of the product IDs entered by the user Each product ID must contain exactly five characters 8

Clearly Visual Basic: Programming with Visual Basic 2008 Let’s Make a Substitution Replace method –Used to replace a sequence of characters in a string with another sequence of character Figure 24-4 –oldValue The sequence of characters that you want to replace in the string –newValue The replacement characters 9

Clearly Visual Basic: Programming with Visual Basic

Clearly Visual Basic: Programming with Visual Basic 2008 I Need To Fit This in Somewhere Insert method –Used to insert characters –Examples Insert an employee’s middle initial within his or her name Insert parentheses around the area code in a phone number 11

Clearly Visual Basic: Programming with Visual Basic

Clearly Visual Basic: Programming with Visual Basic 2008 The Phone Numbers Application Saves (in a sequential access file): –The phone numbers entered by the user Each phone number is entered using: –12 characters in the following format: Before writing a phone number to the file: –The application removes the hyphens and then verifies that the phone number contains 10 characters Figures 24-8 and 24-9 –Show code and resulting display for formatted numbers 13

Clearly Visual Basic: Programming with Visual Basic

Clearly Visual Basic: Programming with Visual Basic 2008 Where Does it Begin? IndexOf method –Used to search a string to determine whether it contains a specific sequence of characters –Example Determining whether the area code “(312)” appears in a phone number 15

Clearly Visual Basic: Programming with Visual Basic

Clearly Visual Basic: Programming with Visual Basic 2008 I Just Want a Part of It Substring method –Used to access any number of characters contained in a string Figure –startIndex The index of the first character you want to access in the string –count argument Specifies the number of characters you want to access 17

Clearly Visual Basic: Programming with Visual Basic

Clearly Visual Basic: Programming with Visual Basic 2008 The Rearrange Name Application User interface –Provides a text box for entering a person’s first name followed by a space and the person’s last name Application –Rearranges name so that the last name comes first, followed by a comma, a space, and the first name Figure –Shows code to display rearranged name 19

Clearly Visual Basic: Programming with Visual Basic

Clearly Visual Basic: Programming with Visual Basic 2008 I Like This Operator Like operator –Allows you to use pattern-matching characters to determine whether one string is equal to another Figure –In the syntax, both string and pattern must be String expressions However, pattern can contain one or more of the pattern-matching characters listed in the figure 21

Clearly Visual Basic: Programming with Visual Basic

Clearly Visual Basic: Programming with Visual Basic

Clearly Visual Basic: Programming with Visual Basic 2008 Modifying the Product ID Application Ensure that the five characters in the product ID are three letters followed by two numbers 24

Clearly Visual Basic: Programming with Visual Basic 2008 Summary String’s Length property –Stores an integer that represents the number of characters contained in the string Visual Basic –Provides methods that allow you to manipulate strings First character in a string has an index of 0 25