On to… string operations & functions. Concatenation (&) §When we want to combine two character strings into one new (longer) string, we can concatenate.

Slides:



Advertisements
Similar presentations
Manipulating Strings String Functions. VB provides a large number of functions that facilitate working with strings. These are found in Microsoft.VisualBasic.Strings.
Advertisements

Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
Excel Chapter 6 Review slides. How many worksheets are in a workbook, by default? three.
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.
Input Dialog Box An input dialog box can be used to obtain a single item of input from the user Presents a window (dialog box) requesting input Syntax:
Fundamentals of Programming in Visual Basic
Chapter 3 (ctd) Sections (partial) Input/Output NUMBERS & STRINGS.
There is a String type in VB Data TypePrefix Stringstr Dim strFirstName As String strFirstName = “Homer” strFirstName = “” String A String variable can.
VB Built-in Functions School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 5, Monday 2/10/03)
Built-In Functions.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
1 Pertemuan 04 Expression Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Comparing Numeric Values If Val(Text1.Text) = MaxPrice Then (Is the current numeric value stored in the Text property of Text1 equal to the value stored.
Introduction to Computing Dr. Nadeem A Khan. Lecture 14.
Introduction to Computing Dr. Nadeem A Khan. Lecture 6.
Declarations/Data Types/Statements. Assignments Due – Homework 1 Reading – Chapter 2 – Lab 1 – due Monday.
Introduction to Computing Dr. Nadeem A Khan. Lecture 13.
CHAPTER 6 FILE PROCESSING. 2 Introduction  The most convenient way to process involving large data sets is to store them into a file for later processing.
Section 3.6 BUILT-IN FUNCTIONS involving numbers & strings.
1 Lab Session-VIII CSIT-121 Spring 2002 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 13 Strings and File I/O  Read Bishop, Chapter 9.  Lab #13 and Homework #13 due next week.
Database Management Review for Final (Part 1) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Wednesday 4/30/2003)
Strings PART II STRING$ AND SPACE$. Create strings of specified number String$ creates string of specified character Space$ creates string of spaces Example:
05/09/2015SJF L31 F21SF Software Engineering Foundations Formatting Converting numbers to Strings and vice versa Monica Farrow EM G30
CS0004: Introduction to Programming Input and Output.
Intrinsic Functions Pre-coded Functions Used to improve developer productivity Broad Range of Activities Math calculations Time/Date functions String.
Introduction to SPSS Edward A. Greenberg, PhD
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,
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Manipulating Text In today’s lesson we will look at: why we might want to pick out parts of text strings some BASIC functions that can be used to chop.
1 Revision on Foxpro Commands Print command (?) e.g.? 6/2 * 3 9 SET DECIMAL TO integer e.g.SET DECIMAL TO 4 ? 2 / SET( ) function e.g.? SET (‘DECIMAL’)
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.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
Numbers continued The Integer Data Type Multiple Declarations Parentheses Three Types of Errors.
Operations on Strings. 8/8/2005 Copyright 2006, by the authors of these slides, and Ateneo de Manila University. All rights reserved L: String Manipulation.
‘Tirgul’ # 2 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #2.
Chapter 51 Decisions Relational and Logical Operators If Blocks Select Case Blocks.
Introduction to Programming Fundamentals of Programming in Visual Basic.
1 STRINGS String data type Basic operations on strings String functions String procedures.
1 Chapter 3 – Examples The examples from chapter 3, combining the data types, variables, expressions, assignments, functions and methods with Windows controls.
5.6 String Processing Part 2. Sprintf(destnvar,…..regularprintf) Write formatted data to string Same as printf except the output is put in variable. A.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Introduction to Computing Dr. Nadeem A Khan. Lecture 7.
Visual Basic.net Functions. Function (Defined) A procedure that returns a value when called.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
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)
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
3.4 Strings Variables and Strings Using Text Boxes for Input and Output Concatenation ANSI Character Set String Properties and Methods: LengthToUpper TrimToLower.
Expressions and Data Types Professor Robin Burke.
Input and Output Output Prompt: –A message displayed to the user indicating what they are to enter. Should be clear and exact on what you want. write:
1 VB-06-String Manipulation Mar 03, 2002 String Function VISUAL BASIC.
CSC 162 Visual Basic I Programming. String Functions LTrim( string ) –Removes leading spaces from the left side of string RTrim( string ) –Removes trailing.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 this week – last section on Friday. Assignment 4 is posted. Data mining: –Designing functions.
13/06/ Strings Left, Right and Trim. 213/06/2016 Learning Objectives Explain what the Left, Right and Trim functions do.
Chapter 3 - Visual Basic Schneider. Private Sub cmdEvaluate_Click() Dim n As Single, root As Single n = 6.76 root = Sqr(n) picResults.Print root; Int(n);
Excel STDEV.S Function.
An Application Uses Variables to Hold Information So It May Be Manipulated, Used to Manipulate Other Information, or Remembered for Later Use.
Microsoft Visual Basic 2005 BASICS
Section 3.3 Numbers Arithmetic Operations Variables
Microsoft Visual Basic 2005 BASICS
Sub Procedures and Functions
Prepared By: Deborah Becker
VBScript Session 10.
Microsoft Visual Basic 2005: Reloaded Second Edition
MapInfo SQL String Functions
Lecture 5 SQL FUNCTIONS.
Presentation transcript:

On to… string operations & functions

Concatenation (&) §When we want to combine two character strings into one new (longer) string, we can concatenate the strings: c = “23” d = “skidoo” e = c & d Picture1.Print e;”!” 23skidoo!

Relating characters & digits §Text boxes can contain only string data, so we must make use of special Visual Basic functions if we want to use this data in a numeric sense. l We know these... Val (“123”) returns the number 123 Str (123) returns the string “123” l These are new... Asc (“A”) returns the number 65 Chr (65) returns the string “A”

Categories of string functions §We have 3 categories of string functions: l Format functions l Those that return a string type result l Those that return a numeric type result Let’s see...

The Format Function §Used to format the display of numeric output data and dates: formatspecifier (num, decplaces) A numeric value or string representation of a numeric value or date; may be a variable An integer that specifies the desired number of decimal places; if omitted, the default value is 2

Examples FormatNumber ( ) FormatCurrency ( ) FormatNumber ( ,0) FormatPercent ( ,1) Format (12345,” ”) Format (12345,” ”) 12, $12, , % bbb12345 bbbb12345

Formatting Dates FormatDateTime(“2/5/01”, vbLongDate) Friday, February 5, 2001

String functions that return string results §These require different numbers of input values but they all return exactly one output value that is character string type: l Left (string, integer_value) l Right (string, integer_value) l Mid (string, integer_value, integer_value) l UCase (string) l Trim (string)

Examples Left (“abcdefg”, 4) returns “abcd” Right (“abcdefg”, 2) returns “fg” Mid (“abcdefg”, 3, 2) returns “cd” UCase (“abCd7f*”) returns “ABCD7F*” Trim (“ abcdefg ”) returns “abcdefg”

String functions that return numeric results §These each receive character string input values and return a unique numeric output value: Len (string) InStr (string1, string2)

Examples Len (“abcdefg”) returns 7 InStr (“abcdefg”, “de”) returns 4 Len (text1.text) returns the length of the input string

Lab §Page 133 # 130 (But input only one word, and replace one character in that word with another character) §Page 133 #131

Homework Due Next Tuesday §Page 135 # 138 §Page 133 # 130 (As stated in the book)