Chapter 3 - Visual Basic Schneider Numeric Variables Used to store numbers Value is assigned by a statement of the form: numVar = expression The variable.

Slides:



Advertisements
Similar presentations
Variables i)Numeric Variable ii)String Variable
Advertisements

1 C++ Syntax and Semantics The Development Process.
VB Numbers and Strings School of Business Eastern Illinois University (Week 4, Monday 2/03/2003) © Abdou Illia, Spring 2003.
Fundamentals of Programming in Visual Basic
Fundamentals of Programming in Visual Basic
Chapter 3 Assignment and Interactive Input. 2 Objectives You should be able to describe: Assignment Operators Mathematical Library Functions Interactive.
Introduction to Computing Dr. Nadeem A Khan. Lecture 8.
Types of LOOP Structures Do While ……. Loop Do Until …… Loop For …… Next loop.
Chapter 31 Fundamentals of Programming in Visual Basic (Continue IV) Strings Variables and Strings Using Text Boxes for Input and Output Concatenation.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
The Class String. String Constants and Variables  There is no primitive type for strings in Java.  There is a class called String that can be used to.
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will Learn about arrays One-dimensional arrays Two-dimensional arrays Learn about searching.
Chapter 31 Fundamentals of Programming in VB(Continue I) Numbers Arithmetic Operations Variables Incrementing the Value of a Variable.
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
Chapter 6 - Visual Basic Schneider
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
Fundamentals of Programming in Visual Basic
Introduction to Computing Dr. Nadeem A Khan. Lecture 9.
1 Chapter 6 Repetition. 2 Outline & Objectives Loop Structure Loop Structure Elements of a Loop Structure Elements of a Loop Structure Processing Lists.
1 Character Strings and Variables Character Strings Variables, Initialization, and Assignment Reading for this class: L&L,
Variables & Math Operators CE 311 K - Introduction to Computer Methods Daene C. McKinney.
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Programming Practice in Visual Basic The Initial Visual Basic Screen Toolbox Project Explorer window Properties window Form Menu bar Description pane.
Fundamentals of Programming in Visual Basic
Created By Mayson Al-Duwais1. Using Exit to Terminate Repetition Statements To terminate different types of repetition statements you can use a special.
A First Book of ANSI C Fourth Edition
Review for Exam 2 School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 10, Friday 3/21/2003) - IF Blocks - Do Loops - Select.
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.
Chapter 3 Processing and Interactive Input. 2 Assignment  The general syntax for an assignment statement is variable = operand; The operand to the right.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
A First Look at Java Chapter 2 1/29 & 2/2 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Chapter 6 - Visual Basic Schneider 1 Chapter 6 Repetition.
CHAPTER SIX LOOPS © Prepared By: Razif Razali 1. FORMAT OR REFRESH!! WHAT HAVE WE LEARN? Differentiate between the types of selection structure? Which.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Numbers continued The Integer Data Type Multiple Declarations Parentheses Three Types of Errors.
CHAPTER 4 GC 101 Data types. DATA TYPES  For all data, assign a name (identifier) and a data type  Data type tells compiler:  How much memory to allocate.
Chapter 8 - Visual Basic Schneider
Repetition Chapter 6 - Visual Basic Schneider 1  Loop Structure  Elements of a Loop Structure  Processing Lists of Data with Do Loops Chapter 6 -
More about Java Chapter 2 9/8 & 9/9 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Chapter 2 Variables.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
CHAPTER 2 C++ SYNTAX & SEMANTICS #include using namespace std; int main() { cout
Introduction to Programming Fundamentals of Programming in Visual Basic.
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
Strings See Chapter 2 u Review constants u Strings, concatenation and repetition 1.
Chapter six exercises
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
3.4 Strings Variables and Strings Using Text Boxes for Input and Output Concatenation ANSI Character Set String Properties and Methods: LengthToUpper TrimToLower.
For Friday Read No quiz Program 6 due. Program 6 Any questions?
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Chapter 4 - VB 2008 by Schneider1 Chapter 4 – Decisions 4.1 Relational and Logical Operators 4.2 If Blocks 4.3 Select Case Blocks.
Week 4 Relational and Logical Operators Dr. Jennifer Cunningham.
Select Case Blocks School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 8, Monday 3/03/2003)
Chapter 7 Arrays.
Fundamentals of Programming in Visual Basic
Chapter 4 - Visual Basic Schneider
Examples of Primitive Values
Strings(Part 1) String Literal and String Variable
String Variable, Methods and Properties
Fundamentals of Programming in Visual Basic
String Variable, Methods and Properties
String Variable, Methods and Properties
String Variable, Methods and Properties
Data Types and Expressions
Presentation transcript:

Chapter 3 - Visual Basic Schneider Numeric Variables Used to store numbers Value is assigned by a statement of the form: numVar = expression The variable must be on the left and the expression on the right.

Chapter 3 - Visual Basic Schneider Assignment Statement: The statement var = expr assigns the value of the expression to the variable tax = 0.02 * (income * dependents) sum = 2 + x y

Chapter 3 - Visual Basic Schneider Valid Numeric Variable Names: timeElapsed taxRate speed n celsius

Chapter 3 - Visual Basic Schneider Invalid Numeric Variable Names: maximum/average 1stChoice square yard

Chapter 3 - Visual Basic Schneider Valid Assignment Statements count = count + 1 num = 5 count = count + num /2

Chapter 3 - Visual Basic Schneider Invalid Assignment Statements 10 = count count + 1 = count

Chapter 3 - Visual Basic Schneider Visual Basic Print Statement Print is a method used to display data on the screen or printer. Can be used to display values of variables or expressions

Chapter 3 - Visual Basic Schneider Examples of Print Statements Private Sub cmdCompute_Click() picResults.Print picResults.Print picResults.Print 3 * 2 picResults.Print 3 / 2 picResults.Print 3 ^ 2 picResults.Print 2 * (3 + 4) End Sub

Chapter 3 - Visual Basic Schneider Examples of Print Statements picOutput.Print speed picOutput.Print taxRate picOutput.Print “Class average is”; total / 3

Chapter 3 - Visual Basic Schneider Examples of Print Statements x = 15 y = 5 picOutput.Print (x + y) / 2, x / y Output: 103

Chapter 3 - Visual Basic Schneider String Constants: A sequence of characters treated as a single item The characters in a string must be surrounded by double quotes (“ ”)

Chapter 3 - Visual Basic Schneider Valid String Constants “A rose by any other name” “9W” “134.23” “She said, ‘stop, thief!’ ”

Chapter 3 - Visual Basic Schneider Invalid String Constants ‘Down by the Seashore’ “ “She said, “Stop, thief!””

Chapter 3 - Visual Basic Schneider String Variables A string variable stores a string. The rules for naming string variables are identical to those for naming numeric variables. When a string variable is first declared, its value is the empty string.

Chapter 3 - Visual Basic Schneider String Variable Example Private Sub cmdShow_Click() picOutput.Cls phrase = "win or lose that counts." picOutput.Print "It's not whether you "; phrase picOutput.Print "It's whether I "; phrase End Sub

Chapter 3 - Visual Basic Schneider Concatenation Two strings can be combined by using the concatenation operation. The concatenation operator is the ampersand (&) sign.

Chapter 3 - Visual Basic Schneider Examples of Concatenation: strVar1 = “Hello” strVar2 = “World” picOutput.Print strVar1& strVar2 txtBox.Text = “32” & Chr(176) & “ Fahrenheit”

Chapter 3 - Visual Basic Schneider Declaring Variable Types Use the Dim statement to declare the type of a variable. Examples: Dim number As Integer Dim flower As String Dim interestRate As Single