VB Numbers and Strings School of Business Eastern Illinois University (Week 4, Monday 2/03/2003) © Abdou Illia, Spring 2003.

Slides:



Advertisements
Similar presentations
/ 251 Internet Applications Ahmed M. Zeki Sem – / Chapter 8.
Advertisements

Lecture 2 Introduction to C Programming
Introduction to C Programming
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Fundamentals of Programming in Visual Basic
1.
Fundamentals of Programming in Visual Basic
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
CMT Programming Software Applications
Chapter 2 Basic Elements of Fortan
Chapter 2: Introduction to C++.
JavaScript, Third Edition
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
Fundamentals of Programming in Visual Basic
A First Book of ANSI C Fourth Edition
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
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.
CS0004: Introduction to Programming Variables – Strings.
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
Tutorial 61 List Box Control Can be used to display a set of choices from which the user can select only one You also can create multi-selection list boxes.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
Chapter 2: Using Data.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Sub procedures School of Business Eastern Illinois University © Abdou Illia, Spring 2002 (Week 6, Friday 2/21/03)
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Week 1 Algorithmization and Programming Languages.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Numbers continued The Integer Data Type Multiple Declarations Parentheses Three Types of Errors.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Sequential files School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 12, Monday 4/07/2003)
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Introduction to Programming Fundamentals of Programming in Visual Basic.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Review for Final (Part 2) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Friday 5/2/2003)
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
Chapter 3 - Visual Basic Schneider Numeric Variables Used to store numbers Value is assigned by a statement of the form: numVar = expression The variable.
1 Chapter 2: Java Fundamentals cont’d Spring Lory Al Moakar.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Select Case Blocks School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 8, Monday 3/03/2003)
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Chapter 6 JavaScript: Introduction to Scripting
Chapter 2 Introduction to C++ Programming
BASIC ELEMENTS OF A COMPUTER PROGRAM
Variables, Expressions, and IO
2.1 Parts of a C++ Program.
Introduction to C++ Programming
WEB PROGRAMMING JavaScript.
Additional Topics in VB.NET
Chapter 2: Introduction to C++.
Introduction to Programming
Introduction to C Programming
Presentation transcript:

VB Numbers and Strings School of Business Eastern Illinois University (Week 4, Monday 2/03/2003) © Abdou Illia, Spring 2003

2 Numbers and Strings n Most data processing performed using Numbers and Strings n Examples of Numbers: Amount of sales, Student’s grades, Regular commission, Sales’ commission n Examples of Strings: Employee name, Student name, "Success", "Unsuccess". n A Number or a String could be a Variable or a Constant. – Numeric Variable or Numeric Constant – String Variable or String Constant

3 Variables n A storage location in main memory whose value can change during program execution. n These storage locations can be referred to by their names. Ex: EmployeeName n Every variable has three properties: a Name, a Value, and a Data Type. n Types of variables: Numeric and String

4 Rules for Creating Variable Names n Must begin with a letter. n Can contain letters, numeric digits. n Can have up to 255 characters. n Can Not be restricted keyword. Examples of valid Variable names EmployeeName RegCom Speed n Celsius Examples of invalid Variable names 1stChoice Name Picture Max/Min

5 Valid / Invalid Numeric Constants Integer Real number Invalid: 6.8% 33- $ & Valid

6 String Constants n A group of alphanumeric data consisting of any type of symbols. n Must be surrounded by quotation marks n Valid String Constants: "Down By the Sea Shore" "She said, ‘stop, thief!’" "134.23" n Invalid String Constants: ‘Down by the Seashore’ " "She said, "Stop, thief!""

7 Arithmetic Operations & Hierarchy of Operations Hierarchy Operator Operator Level 1 ^ Exponentiation * Multiplication / Division + Addition - Subtraction Note: If any, expressions in parentheses ( ) evaluated first Level 2 Level 3

8 Examples Evaluate the following expressions: x = 3 * / 3 x = 4 ^ (8 / 4) y = / (3 * (10 - 9)) z = ^ 2 m = 6 / 3 + 3

9 Assignment Statements for assigning values to variables Examples for Numeric & String variables EmployeeName = "Bill O’Brien" BasePay = 300 ExtraPay = BasePay *.03 WeeklyPay = BasePay + ExtraPay General syntax VariableName = Value Where:VariableName is the variable’s name Value is a constant, a variable or an expression Rules 1.Only a single variable name at the left of the = sign 2.Only a single variable name, constant or expression to the right of the = 3.Everything to the right of the = must be known to the computer

10 Visual Basic Print Statement n Print is a method used to display data on the screen or a printer. n Usually used to display numbers and strings on objects General syntax ObjectName.Print Outputlist Where:ObjectName is the name of the object/device on witch to display Outputlist represent a list of constants, a variables or an expressions Examples frmIdentity.Print " Bill O’Brien " Printer.Print " Bill O’Brien " picOutput.Print 2 * (3 + 4) picOutput.Print " The class average is "; Total / 23 PicOutput.Print 32 & Chr(176) & " Fahrenheit " & is used for concatenation Gives ° which is the 176th ANSI character (See Appendix A)

11 Example

12 Data Types Each variable should be assigned a data type. n Numeric variables’ data types – Single (for storing real numbers) – Integer (for storing integers) n String variables’ data type – String

13 Declaring Variable Types n Dim statements are used to declare data type Example: Dim BasePay As Single Dim NomberOfDays As Integer Dim EmployeeName As String

14 Internal Documentation n An apostrophe ( ' ) can be used to indicate comments; comments are ignored by Visual Basic. n The keyword Rem can also be used instead of an apostrophe for comments. n Remarks can also be placed after program statement too.

15 Formatting Output with Print zones n Using commas (,) allows to print data items in different print zones n Using semicolons (;) allows to print data items one after another n Using Tab allows to print data items at target positions – E.g. Tab (25) allows to move the cursor at position 25 in the line LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLI…. Zone 1 Zone 2 Zone 3 Zone 4 Print Zones

16 Input from Input box General syntax InputBox(Prompt, [Title]) Where:Prompt is a string that tells the user what information to type Title is the caption that appear in the title bar Example EmployeeName = InputBox("Enter Client name", "Name") Will show the input box below to the user. The data typed by the user in the Text box will be assigned to the variable EmployeeName.

17 Input from a file Use Notepad to create a sequential file 1) Start/Programs/Accessories/Notepad to open Notepad 2) Type the following content in Notepad: 3) Save the file under the name "Account.txt" Read data from a sequential file: Syntax Open " FileName" For Input As #n Input #n, Var1, Var2, Var3…Varn Close #n Where:. FileName is the name of the file that contains data to be read. n is the reference number of the file (could be 1, 2, 3, …). Var1, Var2, Var3…Varn, are the names of the variable that will assigned data items read from the file. "CL001","Bill O’Brien",234,7,24 "CL002","John Diaz",321,10,15 "CL003","Nathalie Cole",543,12,16 "CL004","George Pataki",231,6,20