Slides - Chapter 3

Slides Chapter 3 - CHAPTER 3 VARIABLES AND CALCULATIONS 1 BMGT 302 Business Application Programming By Peng Huang R.H Smith School of Business

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
C HAPTER 3 V ARIABLES AND C ALCULATIONS BMGT 302 Business Application Programming By Peng Huang R.H. Smith School of Business, University of Maryland 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
I NTERNAL M EMORY Internal memory : a component inside a computer comprised of memory locations Each memory location has a unique numeric address and can hold only one item at a time A programmer can reserve memory locations by assigning Name : more descriptive words instead of address Data type : indicates the type of data the memory location will store Initial value Two types of memory locations that a programmer can declare: variables and constants 2
Background image of page 2
I NTERNAL M EMORY ( CONT ' D .) Figure 3-1: Illustration of storage bins 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
V ARIABLES Variables : computer memory locations used to temporarily store data while an application is running Contents can change during run time Use a meaningful variable name that reflects the purpose of the variable Use camel casing for variable identifiers Variable names should conform to naming rules 4
Background image of page 4
How to name a variable 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
V ARIABLES ( CONT ' D .) Each variable must be assigned a data type , which determines the memory location’s data type Each data type is a class (OOP) Integer , Long , or Short data types can store integers (whole numbers) Decimal , Double , and Single data types: store real numbers (numbers with a decimal place) Char data type: stores one Unicode character String data type: stores multiple Unicode characters 6
Background image of page 6
V ARIABLES ( CONT ' D .) Unicode : Universal coding scheme for characters that assigns a unique numeric value to each character Other data types Boolean data type: stores a value of True or False Date data type: stores date and time information Object data type: stores any type of data Computer must determine the data type at run time, making it more inefficient 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basic data types in Visual Basic 8 floating-point numbers achieve their greater range at the expense of precision
Background image of page 8
D ECLARING A V ARIABLE IN C ODE Declaration statement : used to declare, or create, a variable Declaration statement includes: Scope/lifetime keyword: Dim , Private , or Static Name of the variable and data type Initial value (optional) Initialization If not explicitly initialized: Numeric data types: automatically initialized to 0 String data type: automatically initialized to Nothing Boolean data type: initialized to False 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
How to declare a variable D ECLARING A V ARIABLE IN C ODE ( CONT D .) 10
Background image of page 10
How to declare a variable (cont’d.) D ECLARING A V ARIABLE IN C ODE ( CONT D .) 11
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
A SSIGNING D ATA TO AN E XISTING V ARIABLE Assignment statement : Used to assign values to properties of controls Used to assign values to variables Assignment operator ( = ) : Expression on the right of the = operator is assigned to the variable on the left of the = operator Expression: can contain literal constants , object properties, variables, keywords, or arithmetic operators 12
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/28/2012 for the course INFO BMGT302 taught by Professor Penghuang during the Spring '12 term at Maryland.

Page1 / 60

Slides Chapter 3 - CHAPTER 3 VARIABLES AND CALCULATIONS 1 BMGT 302 Business Application Programming By Peng Huang R.H Smith School of Business

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online