Strings in Visual Basic Words, Phrases, and Spaces.

Slides:



Advertisements
Similar presentations
CSI 1306 PROGRAMMING IN VISUAL BASIC PART 2. Part 2  1. Strings  2. Translating Conditional Branch Instructions  3. Translation Set 2  4. Debugging.
Advertisements

Manipulating Strings String Functions. VB provides a large number of functions that facilitate working with strings. These are found in Microsoft.VisualBasic.Strings.
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
Proyek Queri-queri Lanjut dan Sub-subqueri. Variables dan Data.
Slide 1 VB Programming Fundamentals. Slide 2 Visual Basic Language v VB language is powerful and easy to use v Descendent of BASIC (Beginner's All-Purpose.
 Basically, it’s a sequence of characters.  Character? › Like… a letter. › Or a number. › Or even blank space (like spaces tabs and newlines).
1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction 9.2Streams 9.3Formatting Output with printf 9.4Printing Integers 9.5Printing Floating-Point.
VB Built-in Functions School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 5, Monday 2/10/03)
Chapter 9 Formatted Input/Output Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Introduction to Computing Dr. Nadeem A Khan. Lecture 6.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
JavaScript, Third Edition
On to… string operations & functions. Concatenation (&) §When we want to combine two character strings into one new (longer) string, we can concatenate.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
Ping Zhang 10/08/2010.  You can get data from the user (input) and display information to the user (output).  However, you must include the library.
BACS 287 Visual Basic String Manipulation. BACS 287 Visual Basic Strings In Visual Basic, a “string” is a series of text, numbers, and special characters.
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission.
Strings PART II STRING$ AND SPACE$. Create strings of specified number String$ creates string of specified character Space$ creates string of spaces Example:
Topics Built-in functions commonly used in business applications String functions and formatting Dates and Times Formatting Data for output Error handling.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 9 - Formatted Input/Output Outline 9.1Introduction 9.2Streams 9.3Formatting Output with printf.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Streams Streams –Sequences of characters organized.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
CS0004: Introduction to Programming Input and Output.
Chapter 9 Formatted Input/Output. Objectives In this chapter, you will learn: –To understand input and output streams. –To be able to use all print formatting.
Chapter 9 Formatted Input/Output Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Manipulation Masterclass By the VB Gods. In this masterclass, we will learn how to use some of the string manipulation function such as Len, Right, Left,
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL.
Chapter 5 Selected Single-Row Functions. Chapter Objectives  Use the UPPER, LOWER, and INITCAP functions to change the case of field values and character.
Input, Output, and Processing
Strings The Basics. Strings can refer to a string variable as one variable or as many different components (characters) string values are delimited by.
CIS 338: Operators and Formatting in VB.NET Dr. Ralph D. Westfall April, 2011.
Oracle 11g: SQL Chapter 10 Selected Single-Row Functions.
Manipulating Strings. What is a string? Data composed of text characters. The data is stored in consecutive bytes of memory. Each byte stores the ASCII.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
Using Decimal Types. What are the data types that you can use? Decimal Number: Single -Is used for decimal values that will not exceed six or seven digits.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
Chapter 12: String Manipulation Introduction to Programming with C++ Fourth Edition.
Week 6.  Assessment 2  Do Loops  Custom Functions.
‘Tirgul’ # 2 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #2.
H2K Infosys is business based in Atlanta, Georgia – United States Providing Online IT training services world wide. USA - +1-(770) ,
Copyright © Curt Hill Formatting Reals Outputs other than normal.
1 Chapter 3 – Examples The examples from chapter 3, combining the data types, variables, expressions, assignments, functions and methods with Windows controls.
Strings The Basics. Strings a collection data type can refer to a string variable as one variable or as many different components (characters) string.
Advanced Repetition Structure and String Functions (Unit 10) Visual Basic for Applications.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Introduction to Computing Dr. Nadeem A Khan. Lecture 7.
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
1 Inside Module 8 Extracting Data Page n Using the Extract command2 n Coercion3 n $-functions4 n Extract from a table7.
02/03/ Strings Left, Right and Trim. 202/03/2016 Learning Objectives Explain what the Left, Right and Trim functions do.
Strings PART I STRINGS, DATES, AND TIMES. FUNDAMENTALS OF CHARATERS AND STRINGS VB represents characters using American National Standards Institute(ANSI)
CHAPTER FOUR Performing Calculations and Manipulating Data: Expressions.
Gollis University Faculty of Computer Engineering Chapter Five: Retrieval, Functions Instructor: Mukhtar M Ali “Hakaale” BCS.
1 VB-06-String Manipulation Mar 03, 2002 String Function VISUAL BASIC.
Strings CSE 1310 – Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington 1.
CSC 162 Visual Basic I Programming. String Functions LTrim( string ) –Removes leading spaces from the left side of string RTrim( string ) –Removes trailing.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
13/06/ Strings Left, Right and Trim. 213/06/2016 Learning Objectives Explain what the Left, Right and Trim functions do.
Strings in Python String Methods. String methods You do not have to include the string library to use these! Since strings are objects, you use the dot.
Chapter 9 - Formatted Input/Output
Logical Functions Excel Lesson 10.
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL
2. Understanding VB Variables
SQL Text Manipulation Farrokh Alemi, Ph.D.
Chapter 9 - Formatted Input/Output
Sub Procedures and Functions
VBScript Session 10.
VB Variables and Data
MapInfo SQL String Functions
Presentation transcript:

Strings in Visual Basic Words, Phrases, and Spaces

Strings are a series of characters. ä Constant strings never change and are indicated by double quotes. ä Examples: “Fleeb” “Here is a string.”

Strings are a series of characters. ä Variable strings are a special type of variable. ä Example: Dim Fleeb as String ä In any of the following operators and functions you can use either a variable or constant string.

Strings have their own operators and functions. ä Operators for putting strings together. ä Functions for pulling strings apart. ä Functions for creating strings. ä Functions for modifying strings. ä Operators for finding out things about strings.

Putting Strings Together ä & concatenates two strings ä Examples: ä “This “ & “is fun!” becomes “This is fun!” ä “Fleeb” & “norb” & “ski” becomes “Fleebnorbski”

Old Operator ä The + sign can be used for the same purpose, but it is better to use the & since no one will mistake it for addition.

Functions for Pulling Strings Apart ä Left$ - Pulls off the leftmost characters. ä Takes two arguments, ä the string ä the number of characters to pull off ä Examples: ä Left$(“Here is another string”,10) returns “Here is an” ä Left$(“ * 9”,6) returns “6 + 67”

Pulling Strings Apart ä Right$ - Pulls off the rightmost characters. ä Takes two arguments: ä the string ä the number of characters to pull off ä Examples: ä Right$(“Here is another string”,10) returns “her string” ä Right$(“ * 9”,6) returns “67 * 9”

Pulling Strings Apart ä Mid$ - Pulls out characters from middle. ä Takes three arguments ä the string ä the position to start pulling from. ä the number of characters to pull. ä Examples: ä Mid$(“Here is another string”,10,4) returns “noth” ä Mid$(“ * 9”,5,2) returns “67”

Creating Strings ä Str$ - Creates a string from a number. ä CStr - Creates a string from a number. ä Format$ - Allows very complicated formatting of numbers.

Creating Strings ä Format$ - Used with numbers, gives precise formatting control over strings. ä Takes two arguments ä A number ä A descriptor.

Descriptors for Format$ ä Descriptors come in two flavors: system defined and user defined. ä System defined include: General Number, Currency, Fixed, Standard, Percent, Scientific, Yes/No, True/False, On/Off ä User defined are generated using another string. The other string has special characters in it that define how the number should be displayed.

User Defined Format String Characters 0Display a number or zero. #Display a number or nothing..Decimal placeholder %Percentage placeholder.,Thousands seperator EScientific Notation :Time seperator /Date seperator \ ”Literal character indicator.

User Defined Format String Characters ä dDay ä mMonth ä yYear ä hHour ä nMinute ä sSecond ä wDay of Week ä qQuarter

Some Examples of Format ä format( ,” ”) -> ä format(11.1,”####.##”) -> 11.1 ä format( ,”###,###,###”) -> 10,010,021 ä format( ,”#.##E##”) -> 1.00E6

Some Examples of Format Using Time Formats Dim curr_time as double curr_time = Now format(cur_time,”mm/dd/yy hh:nn”) -> 03/06/95 09:15 format(cur_time,”m/d/yy h:n”) -> 3/6/95 9:15

More Examples format(cur_time,”dddd, mmm dd, yyyy”) Wednesday, Dec. 06, 1995

Functions for Modifying Strings ä UCase$ - Make every letter upper case. ä LCase$ - Make every letter lower case. ä Trim$ - Removes leading and trailing spaces from the string.

Modifying Strings ä UCase$ - Make every letter upper case. ä Takes one argument, the string. ä Examples ä UCase$(“Here”) returns “HERE” ä UCase$(“Oh Boy”) returns “OH BOY”

Modifying Strings ä LCase$ - Makes every letter lower case. ä Takes one argument, the string. ä Examples ä LCase$(“Here”) returns “here” ä LCase$(“Oh Boy”) returns “oh boy”

Modifying Strings ä Trim$ - Removes leading and trailing spaces from string ä Takes one argument, the string ä Examples Trim$(“ Here is a string “) returns “Here is a string” ä Also comes in LTrim$ and RTrim$, for removing only one end or the other.

Functions for Finding Things Out About Strings ä Len - Finds out how long the string is. ä InStr - Finding out if one string is in another. ä StrComp - Find out which string is “bigger”.

Finding Out about Strings ä Len - Finds out how long the string is. ä Takes one argument ä A string ä Returns the number of characters in the string.

Finding Out about Strings ä InStr - Finding out if one string is in another. ä Takes two arguments ä The string to look in. ä The string to look for. ä Returns the location of the first occurance of string two in string one. ä If the location equals zero, there is no occurrence of string one in string two.

Finding Out about Strings ä StrComp - Which string is “bigger”. ä Takes two arguments: ä string one ä string two ä Returns: ä -1 if string one < string two ä 0 if they are equal ä 1 if string two < string one

Summary ä String operations can be very useful. ä VB gives particularly strong support for strings.