Microsoft Visual Basic 2005: Reloaded Second Edition - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Microsoft Visual Basic 2005: Reloaded Second Edition

Description:

Microsoft Visual Basic 2005: Reloaded. Second Edition. Chapter 6 ... Microsoft Visual Basic 2005: Reloaded, Second Edition. 4. Manipulating Strings in Visual Basic ... – PowerPoint PPT presentation

Number of Views:79
Avg rating:3.0/5.0
Slides: 35
Provided by: ecpico
Category:

less

Transcript and Presenter's Notes

Title: Microsoft Visual Basic 2005: Reloaded Second Edition


1
Microsoft Visual Basic 2005 Reloaded Second
Edition
  • Chapter 6
  • String Manipulation and More Controls

2
Objectives
  • After studying this chapter, you should be able
    to
  • Determine the number of characters contained in a
    string
  • Remove characters from a string
  • Replace one or more characters in a string
  • Insert characters within a string
  • Search a string for one or more characters

3
Objectives (continued)
  • Access characters contained in a string
  • Compare strings
  • Include radio buttons in an interface
  • Include check boxes in an interface

4
Manipulating Strings in Visual Basic
  • Most applications need to manipulate string data
    in some fashion
  • String properties and methods are used to
    manipulate string data

5
Determining the Number of Characters Contained in
a String
6
Determining the Number of Characters Contained in
a String (continued)
7
Determining the Number of Characters Contained in
a String (continued)
8
Determining the Number of Characters Contained in
a String (continued)
9
Removing Characters from a String
  • TrimStart method removes one or more characters
    from the beginning of a string
  • TrimEnd method removes one or more characters
    from the end of a string
  • Trim method removes one or more characters from
    both the beginning and end of a string
  • Each of these methods returns a string with the
    appropriate characters removed

10
Removing Characters from a String (continued)
11
Removing Characters from a String (continued)
  • trimChars argument
  • Comma-separated list of characters to be removed
  • If omitted, spaces will be removed
  • Default value is the space character

12
Removing Characters from a String (continued)
13
Removing Characters from a String (continued)
14
The Remove Method
  • Remove method
  • Removes characters from a string
  • Can remove one or more characters located
    anywhere in the string
  • Returns a string with the appropriate characters
    removed
  • Index
  • The position of a character in a string
  • Is zero-relative (starts with 0 as first position)

15
The Remove Method (continued)
16
The Remove Method (continued)
17
The Remove Method (continued)
18
The Remove Method (continued)
19
Replacing Characters in a String
  • Replace method replaces a sequence of characters
    in a string with another sequence of characters

20
Replacing Characters in a String (continued)
21
Replacing Characters in a String (continued)
22
Replacing Characters in a String (continued)
23
Replacing Characters in a String (continued)
24
The Mid Statement
  • Mid statement
  • Replaces a specified number of characters in a
    string with characters from another string
  • targetString argument the string in which
    characters are to be replaced
  • replacementString argument the replacement
    characters
  • start argument the starting position for the
    replacement
  • count argument number of characters to replace

25
The Mid Statement (continued)
  • Character position of characters in the string
    starts with 1 (not the same as index)
  • Count argument is optional

26
The Mid Statement (continued)
27
The Mid Statement (continued)
28
The Mid Statement (continued)
29
Inserting Characters in a String
  • PadLeft method inserts characters at the
    beginning of a string
  • PadRight method inserts characters at the end of
    a string
  • length argument represents the total length of
    the desired resulting string
  • character argument
  • The character used to pad the string
  • Default value is the space character

30
Inserting Characters in a String (continued)
31
Inserting Characters in a String (continued)
32
Inserting Characters in a String (continued)
33
Inserting Characters in a String (continued)
34
Inserting Characters in a String (continued)
Write a Comment
User Comments (0)
About PowerShow.com