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

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

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

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

View Full Document
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
I NTERNAL M EMORY ( CONT ' D .) Figure 3-1: Illustration of storage bins 3

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

View Full Document
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
How to name a variable 5

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

View Full Document
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
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

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

View Full Document
Basic data types in Visual Basic 8 floating-point numbers achieve their greater range at the expense of precision
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

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

View Full Document
How to declare a variable D ECLARING A V ARIABLE IN C ODE ( CONT D .) 10
How to declare a variable (cont’d.) D ECLARING A V ARIABLE IN C ODE ( CONT D .) 11

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

View Full Document
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
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
Ask a homework question - tutors are online