3.4 Strings Variables and Strings Using Text Boxes for Input and Output Concatenation ANSI Character Set String Properties and Methods: LengthToUpper TrimToLower.

Slides:



Advertisements
Similar presentations
C ONTINUE... V ARIABLE -N AMING C ONVENTIONS When declaring variables, you should be aware of few naming conventions. A variable’s name: Must begin with.
Advertisements

Chapter 3 – Fundamentals of Programming in VB.NET
Operators Same as standard math operators with 2 exceptions –* for multiplication –^ for exponentiation Order of operations strictly observed –Please Excuse.
Fundamentals of Programming in Visual Basic
Chapter 4 General Procedures
String Variables Visual Basic for Applications 4.
Chapter 31 Fundamentals of Programming in Visual Basic (Continue IV) Strings Variables and Strings Using Text Boxes for Input and Output Concatenation.
Chapter 4 - VB.Net by Schneider1 Chapter 4 General Procedures 4.1 Sub Procedures, Part I 4.2 Sub Procedures, Part II 4.3 Function Procedures 4.4 Modular.
Chapter 31 Fundamentals of Programming in VB(Continue I) Numbers Arithmetic Operations Variables Incrementing the Value of a Variable.
To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.
On to… string operations & functions. Concatenation (&) §When we want to combine two character strings into one new (longer) string, we can concatenate.
In a not gate, if the input is on(1) the output is off (0) and vice versa.
110-D1 Variables, Constants and Calculations(1) Chapter 3: we are familiar with VB IDE (building a form…) to make our applications more powerful, we need.
Variables & Math Operators CE 311 K - Introduction to Computer Methods Daene C. McKinney.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Chapter 31 Fundamentals of Programming in Visual Basic (Continue VI) String Properties and Methods: "Visual".Length is 6. "Visual".ToUpper is VISUAL. "123.
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Created By Mayson Al-Duwais1. Using Exit to Terminate Repetition Statements To terminate different types of repetition statements you can use a special.
Saving and Loading Simple Text Files A sequential file stores characters one after the other like songs on a cassette tape. New characters are added to.
Chapter 3: Using Variables and Constants
CS0004: Introduction to Programming Input and Output.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET VB.NET Controls VB.NET Events Numbers Strings Input and Output.
Chapter 3 - VB 2005 by Schneider1 Chapter 3 – Fundamentals of Programming in Visual Basic 3.1 Visual Basic Controls 3.2 Visual Basic Events 3.3 Numbers.
CS0004: Introduction to Programming Variables – Strings.
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.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Visual Basic.NET BASICS Lesson 4 Mathematical Operators.
Copyright © Curt Hill First Window Builder Program Easy GUIs in Eclipse.
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
Visual Basic IITG to be expanded. What is Visual Basic? Object Oriented Programming Language (OOP) Graphical User Interface (GUI) Event Driven – Write.
1 Chapter 3 – Fundamentals of Programming in Visual Basic 3.1 Visual Basic Controls 3.2 Visual Basic Events 3.3 Numbers 3.4 Strings 3.5 Input and Output.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
CS0004: Introduction to Programming Project 1 – Lessons Learned.
Numbers continued The Integer Data Type Multiple Declarations Parentheses Three Types of Errors.
Applications Development
3.2 VB.NET Events An Event Procedure Properties and Event Procedures of the Form Tab Order of Controls Exercises.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
CS320n –Visual Programming More LabVIEW Foundations.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
1 Advanced Computer Programming Lab Calculator Project.
Chapter 51 Decisions Relational and Logical Operators If Blocks Select Case Blocks.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Chapter 3 - Visual Basic Schneider Numeric Variables Used to store numbers Value is assigned by a statement of the form: numVar = expression The variable.
Lesson 4 Mathematical Operators! October 6, 2009.
Introduction to Files in VB Chapter 9.1, 9.3. Overview u Data Files  random access  sequential u Working with sequential files  open, read, write,
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.
2c – Textboxes and Buttons Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Subroutines (PrArith, Math,projCP1, PrAdrProc, PrAdrProcFunc) Please use speaker notes for additional information!
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Data Types. Visual Basic provides data type Single for storing single-precision floating-point numbers. Data type Double requires more memory to store.
Chapter 3 – Variables, Input, and Output
String Manipulation Reference:
Data Types, Arithmetic Operations
Chapter 3 – Variables, Input, and Output
Chapter 4 – Decisions 4.1 Relational and Logical Operators
Variables and Arithmetic Operations
Microsoft Visual Basic 2005 BASICS
Chapter 3 – Variables, Input, and Output
Fundamentals of Programming in VB.NET
Strings(Part 1) String Literal and String Variable
String Variable, Methods and Properties
Section 3.3 Numbers Arithmetic Operations Variables
Variable Review & IO User 12/26/2018.
String Variable, Methods and Properties
String Variable, Methods and Properties
Introduction to Programming
String Variable, Methods and Properties
Presentation transcript:

3.4 Strings Variables and Strings Using Text Boxes for Input and Output Concatenation ANSI Character Set String Properties and Methods: LengthToUpper TrimToLower IndexOfSubstring

Strings continued The Empty String Initial Value of a String Option Strict Internal Documentation Line-Continuation Character

Variables and Strings Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim today As String today = "Monday" With lstOutput.Items.Clear().Add("hello").Add(today) End With End Sub

Using Text Boxes for Input and Output The contents of a text box is always a string Input example strVar = txtBox.Text Output example txtBox.Text = strVar

Data Conversion Because the contents of a text box is always a string, sometimes you must convert the input or output numVar = CDbl(txtBox.Text) txtBox.Text = CStr(numVar) Converts a String to a Double Converts a number to a string Demo – oneplusone

Concatenation Combining two strings to make a new string quote1 = "The ballgame isn't over, " quote2 = "until it's over." quote = quote1 & quote2 txtOutput.Text = quote & " Yogi Berra" Displays The ball game isn't over until it's over. Yogi Berra Demo – oneplusone modified - ANSI

ANSI Character Set A numeric representation for every key on the keyboard See Appendix A in text book – p. 579 Chr() function displays the value

String Properties and Methods: "Visual".Length is 6. "Visual".ToUpper is VISUAL. "123 Hike".Length is 8. "123 Hike".ToLower is 123 hike. "a" & " bcd ".Trim & "efg" is abcdefg.

More String Properties and Methods: "fanatic".Substring(0, 3) is "fan". "fanatic".IndexOf("ati") is 3. "fanatic".Substring(4, 2) is "ti". "fanatic".IndexOf("a") is 1. "fanatic".Substring(4) is "tic". "fanatic".IndexOf("nt") is –1. Demo 3-4-6

The Empty String The string "", which contains no characters, is called the empty string or the zero-length string. The statement lstBox.Items.Add("") skips a line in the list box. The contents of a text box can be cleared with either the statement txtBox.Clear() or the statement txtBox.Text = ""

Initial Value of a String By default the initial value is Nothing Strings can be given a different initial value as follows: Dim today As String = "Monday"

Option Strict VB.NET allows numeric variables to be assigned strings and vice versa, a poor programming practice. To turn this feature off, put the following statement at the very top of the code window Option Strict On Demo: Commission / oneplusone

Internal Documentation 1.Other people can easily understand the program. 2.You can understand the program when you read it later. 3.Long programs are easier to read because the purposes of individual pieces can be determined at a glance.

Line-Continuation Character A long line of code can be continued on another line by using underscore (_) preceded by a space msg = “This is not the end " & _ “of this line!"

Exercises p together p. 105 Homework – p. 104