Introduction to Computing Dr. Nadeem A Khan. Lecture 11.

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

Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
VB Numbers and Strings School of Business Eastern Illinois University (Week 4, Monday 2/03/2003) © Abdou Illia, Spring 2003.
Introduction to Computing Dr. Nadeem A Khan. Lecture 21.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
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
Introduction to Computing Dr. Nadeem A Khan. Lecture 22.
Introduction to Computing Dr. Nadeem A Khan. Lecture 8.
Introduction to Computing Dr. Nadeem A Khan. Lecture 10.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction to Computing Dr. Nadeem A Khan. Lecture 7.
1 Lecture 2  Input-Process-Output  The Hello-world program  A Feet-to-inches program  Variables, expressions, assignments & initialization  printf()
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
Introduction to Computing Dr. Nadeem A Khan. Lecture 17.
Introduction to Computing Dr. Nadeem A Khan. Lecture 7.
Introduction to Computing Dr. Nadeem A Khan. Lecture 14.
Introduction to Computing Dr. Nadeem A Khan. Lecture 11.
Introduction to Computing Dr. Nadeem A Khan. Lecture 6.
Introduction to Computing Dr. Nadeem A Khan. Lecture 13.
Introduction to Computing Dr. Nadeem A Khan. Lecture 18.
Section Schneider zThis section introduces nice ways to produce input & display output: yInput boxes yMessage boxes.
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.
Introduction to Computing Dr. Nadeem A Khan. Lecture 9.
Introduction to Computing Dr. Nadeem A Khan. Lecture 5.
Chapter 3: Using Variables and Constants
Introduction to Python
E0001 Computers in Engineering
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
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.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Chapter 8 - Visual Basic Schneider
Variables, Expressions and Statements
Chapter 7 P 1 Lists and Loops List boxes and combo boxes List box - list of items - useful for a list which does not change Combo box - list of items -
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
Introduction to Programming Fundamentals of Programming in Visual Basic.
Chapter 7 - Lists, loops and printing w List boxes and combo boxes several types can add items at design time or during run time user select from predefined.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
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.
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.
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
Introduction to Computing Dr. Nadeem A Khan. Lecture 7.
Introduction to Computing Dr. Nadeem A Khan. Lecture 9.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Visual Basic. The Close Method The Close method is used to close a form. To close a form use the keyword Me to refer to the form. Me.Close()
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
Introduction to Python Lesson 2a Print and Types.
A variable is a name for a value stored in memory.
Computing Fundamentals
Variables, Expressions, and IO
Introduction to C++ Programming
WEB PROGRAMMING JavaScript.
Prepared By: Deborah Becker
Additional Topics in VB.NET
Introduction to Programming
JavaScript: Introduction to Scripting
Primitive Types and Expressions
Unit 3: Variables in Java
Presentation transcript:

Introduction to Computing Dr. Nadeem A Khan

Lecture 11

Data Types !

► For Strings:  Variable-Length String  Fixed-Length Strings Data Types

► For Numbers (Whole numbers or not):  Single (Precision Floating Point)  Double (Precision Floating Point)  Currency Data Types (Contd.)

► For Numbers (Whole numbers only):  Integer  Long (Integer)  Byte Data Types (Contd.)

► For Boolean values:  Boolean Data Types (Contd.)

► Use Letters, digits and underscores only  No predefined keywords (integer, single, Dim etc.) ► Max. length: 255 chars. (Min. length: 1 char.) ► Begin with a letter (e.g. a, A) ► Case-Insensitive (Game=GAME=gAme) Variable Names

► Use meaningful names ► Good to follow the naming conventions e.g: e.g: total total numberOfCars numberOfCars Variable Names (Contd.)

Converting Data Types !

► Already know:  Val  Str$ Conversion functions

► Conversion FunctionsConverts to  CboolBoolean  CbyteByte  CcurCurrency  CDblDouble  CintInteger  CLngLong  CsngSingle  CstrString Conversion functions (Contd.)

► Converts the input value to a specific data type ► Only convert those input values that are appropriate for that data type for that data type Conversion functions (Contd.)

Using commas: Example Using commas: Example ► Picture1.Print “North”, “to”, “the”, “future” ► Picture1.Print “No:”, 6, More on Print method

Using commas: Result Using commas: Result ► North to the future ► No: 6 (‘6’ displayed 1 pos. further in zone) More on Print method (Contd.)

Using commas: Rules Using commas: Rules ► Line of a Picture Box divided in zones ► A Zone: 14 positions ► Print Items displayed in consecutive zones More on Print method

Using the Tab function: Example Using the Tab function: Example ► Picture1.Print “Hello”;Tab(10); “World”; Tab(20);”!” ► Picture1.Print “No:”;Tab(5);5 More on Print method

Using the Tab function: Result Using the Tab function: Result ► HelloWorld!(‘World’ at 10th position) (‘!’ at 20th position) (‘!’ at 20th position) ► No: 5 (‘5’ at 6th position) More on Print method (Contd.)

Using the Tab functions: Rules Using the Tab functions: Rules ► Tab(n); (where n is a positive integer) =>Following Item (if possible) displayed beginning at the nth position of the line =>Following Item (if possible) displayed beginning at the nth position of the line More on Print method

Using the Spc function: Example Using the Spc function: Example ► Picture1.Print “Hello”;Spc(3); “World” ► Picture1.Print “No:”;Spc(3);5 More on Print method

Using the Spc function: Result Using the Spc function: Result ► Hello World(“World” after 3 spaces) ► No: 5 (“5” after 4 spaces) More on Print method (Contd.)

Using the Spc functions: Rules Using the Spc functions: Rules ► Spc(n); (where n is a positive integer) =>Following Item printed after n spaces =>Following Item printed after n spaces More on Print method

Output to the Printer: Output to the Printer: ► Printer.Print expr =>sends expression expr to the printer =>works the same way as Picture1.Print More on Print method

Output to the Printer: Output to the Printer: Let Printer.FontName = “Script” Let Printer.FontBold = True Let Printer.FontSize = 12 => set properties More on Print method (Contd.)

Output to the Printer: Output to the Printer: ► Printer.NewPage (new page) ► Printer.EndDoc (document ended) ► PrintForm (performs the screen dump) More on Print method (Contd.)

► MsgBox message,, “Caption” ► A Message Box will appear  displaying the string message  ‘Caption’ will appear in the title bar The Message Box for Output

► Let stringVar = InputBox$(message) ► =>An InputBox will appear displaying the string message; Assigns the typed user response to stringVar after Enter is pressed or OK is clicked The Input Box for Input

► Open “filespec” For Input As #n  Opens a file for reading and assigns the reference number n ► Input #n, var  Next available item is read from the file and assigned to variable var ► Close #n  Closes the file Reading Data from File

► DATA.TXT file has two lines: “September”26 => items separated by commas or line-breaks; data item of same type as the data to be data item of same type as the data to be assigned to the corresponding variable assigned to the corresponding variable Reading Data from File (Contd.)

Example: Sub Command1_Click() Dim month As String, date As Single Picture1.Cls Open “DATA.TXT” For Input As #1 Input #1, month Input #1, date Picture1.Print “ Today is ”; month; date Close #1 End Sub Reading Data from File (Contd.)

The result: Today is September 26 Reading Data from File (Contd.)

► Rem text ► ……………….. ‘text e.g: Rem Compute weekly pay Dim hrs as Single ‘hours worked Inclusion of Comments

Reading for today ► Schneider: Section 3.5