Selection Structures ; String Functions. If…Then…Else If condition Then [instructions when the condition is true] [Else [instructions when the condition.

Slides:



Advertisements
Similar presentations
Integrated Business Applications with Databases (D3) Jenny Pedler
Advertisements

CSI 1306 PROGRAMMING IN VISUAL BASIC PART 2. Part 2  1. Strings  2. Translating Conditional Branch Instructions  3. Translation Set 2  4. Debugging.
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Control Structures Nested ifs, switch statements.
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.
Slide 1 VB Program Flow Control. Slide 2 Making Decisions v Decision Statement: control the execution of parts of the program based on conditions. v The.
There is a String type in VB Data TypePrefix Stringstr Dim strFirstName As String strFirstName = “Homer” strFirstName = “” String A String variable can.
Built-In Functions.
1 Pertemuan 05 Selection 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.
Note The first half of these slides duplicate previous slides. The second half are original.
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
A variable (X) is declared as an integer Data Type, meaning it can only accept numeric values The Text Box is named BoxContents The Variable X is assigned.
Chapter 51 Select Case block A decision-making structure that simplifies choosing among several actions. Avoids complex nested If constructs. If blocks.
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.
Microsoft Visual Basic 2008: Reloaded Fourth Edition
Tutorial 11 Using and Writing Visual Basic for Applications Code
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
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,
Using the selection structure (Unit 7) Visual Basic for Applications.
Chapter 5 – Decisions 5.1 Relational and Logical Operators 5.2 If Blocks 5.3 Select Case Blocks.
Lecture Set 5 Control Structures Part A - Decisions Structures.
ENGR 112 Decision Structures.
Selection Structure If... Then.. Else Case. Selection Structure Use to make a decision or comparison and then, based on the result of that decision or.
Variables,Constants and Data types Variables temporarily stores values during the execution of an application Variables have a name and data type Declare.
Introduction to VB.NET 2005 Dr. McDaniel IDS4704 Spring 2005.
Control Structures.  Need to have program statements that control execution flow  Simple statements to branch execution based on conditions (If/Then/Else)
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
‘Tirgul’ # 2 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #2.
1 Week 5 More on the Selection Structure. 2 Nested, If/ElseIf/Else, and Case Selection Structures Lesson A Objectives After completing this lesson, you.
String and General Procedures. Answer to the last question of Exam 1 Start Get a number Divide the Number By 2 Is the quotient Equal to 1? Print The Remain.
Visual Basic Programming I 56:150 Information System Design.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
H2K Infosys is business based in Atlanta, Georgia – United States Providing Online IT training services world wide. USA - +1-(770) ,
Advanced Programming Strings Arrays Arguments Modulus.
1 Microsoft® Visual Basic®.NET Language # 2. 2 Flow-Control Statements If … End If Select Case … End Select For… Next Do … Loop Exit.
Java – Variables and Constants By: Dan Lunney. Declaring Variables All variables must be declared before they can be used A declaration takes the form:
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.
Tutorial 4: The Selection Structure 1 Tutorial 4 The Selection Structure.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 11 So Many Paths … So Little Time.
Chapter 10 So Many Paths … So Little Time (Multiple-Alternative Selection Structures) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Python Strings. String  A String is a sequence of characters  Access characters one at a time with a bracket operator and an offset index >>> fruit.
Writing Basic SQL SELECT Statements Lecture
CSC 162 Visual Basic I Programming. String Functions LTrim( string ) –Removes leading spaces from the left side of string RTrim( string ) –Removes trailing.
TUTORIAL 4 Visual Basic 6.0 Mr. Crone. Pseudocode Pseudocode is written language that is part-code part- English and helps a programmer to plan the layout.
1 Comparing Strings zLcase(string) --- converts a string to lower case Mystring = lcase(yourstring) zUcase(string) --- converts a string to upper case.
Java String Methods - Codehs
Kondisi dan Perulangan
Kondisi dan Perulangan
Making Decisions in a Program
Controlling Execution
Chapter 6 Variables What is VBScript?
VBScript Session 4 Dani Vainstein.
Boolean Expressions and If statements
البرمجة بلغة فيجول بيسك ستوديو
Lists in Python.
Chapter 3: Introduction to Problem Solving and Control Statements
Objectives After studying this chapter, you should be able to:
Lesson Plan Instructional Objective Learning Objective
Function Procedures.
Writing Basic SQL SELECT Statements
Microsoft Visual Basic 2005: Reloaded Second Edition
Basic String Operations
The Data Element.
Topics Basic String Operations String Slicing
MapInfo SQL String Functions
Topics Basic String Operations String Slicing
The Data Element.
Topics Basic String Operations String Slicing
Presentation transcript:

Selection Structures ; String Functions

If…Then…Else If condition Then [instructions when the condition is true] [Else [instructions when the condition is false]] End If If condition Then … [Else … ]

Select Case selection structure Select Case testexpression [Case expressionlist1 [instructions for the first Case]] [Case expressionlist2 [instructions for the second Case]] [Case expressionlistn [instructions for the nth Case]] [Case Else [instructions for the default case]] End Select

Dim intPosition as Integer intPosition = Val(txtPosition.Text) Select Case intPosition Case 1 picOutcome.Print "Win" Case 2 picOutcome.Print "Place" Case 3 picOutcome.Print "Show" Case 4, 5 picOutcome.Print ”Almost!" Case Else picOutcome.Print "Out of luck.” End Select

Is and To Use the To keyword to specify a range of values when you know both the minimum and maximum values in the range. Use the Is keyword to specify a range of values when you don’t know both the minimum and the maximum values in the range.

Private Sub cmdDescribe_Click() Dim intPosition as Integer intPosition = Val(txtPosition.Text) Select Case intPosition Case 1 To 3 picOutcome.Print "In the money." picOutcome.Print "Congratulations!" Case Is > 3 picOutcome.Print "Not in the money" End Select End Sub

Select Case statements (cont.) You can use multiple expressions or ranges in each Case clause. Case 1 To 4, 7 To 9, 11, Is > MaxNumber Select Case statements can be nested.

UCase Function Returns a string containing the specified string, converted to uppercase. Syntax: UCase(string) Examples: Dim strConvert, strTemp As String strTemp = “ants” strTemp = UCase(strTemp) strConvert = UCase(“Allyson”)

LCase Function Returns a string that has been converted to lowercase. Syntax: LCase(string) Examples: Dim strConvert, strTemp As String strTemp = “Ronald McDonald” strTemp = Lcase(strTemp) strConvert = LCase(“Allyson”)

Len Function Returns a Long containing the number of characters in a string. Syntax: Len(string or variablename) Example: MyString = "Hello World" MyLen = Len(MyString) 'Returns 11.

Left Function Returns a Variant (String) containing a specified number of characters from the left side of a string. Syntax: Left(string, length) Examples: AnyString = "Hello World" MyStr = Left(AnyString, 1) MyStr = Left(AnyString, 7)

Right Function Returns a string containing a specified number of characters from the right side of a string. Syntax: Right(string, length) Examples: AnyString = "Hello World” MyStr = Right(AnyString, 1) MyStr = Right(AnyString, 6)

Mid Function Returns a string containing a specified number of characters from a string. Syntax: Mid(string, start[, length]) Examples: MyString = "Mid Function Demo” FirstWord = Mid(MyString, 1, 3) LastWord = Mid(MyString, 14, 4) MidWords = Mid(MyString, 5)