0% found this document useful (0 votes)
23 views

Data Type Reference

This document provides a reference guide for selecting appropriate data types in programming based on the attributes of the data. It includes a decision tree that guides the user to choose between data types like short, integer, long, decimal, date, boolean, character, and others based on questions about the data's numeric format, range, use in math operations, whole number requirement, and byte size range. The data type, size in bytes, and range for each type is also provided.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Data Type Reference

This document provides a reference guide for selecting appropriate data types in programming based on the attributes of the data. It includes a decision tree that guides the user to choose between data types like short, integer, long, decimal, date, boolean, character, and others based on questions about the data's numeric format, range, use in math operations, whole number requirement, and byte size range. The data type, size in bytes, and range for each type is also provided.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Data Type Reference Guide

Data Type Range Bytes

Is the data numeric?

No

Use Boolean, String or Date, as appropriate

Accept a Decimal?

Short Integer Long

-32,768 to 32,767 -2,147,483,648 to 2,147,483,647 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 1.0e-28 to 7.9e28 Jan 1, 0001 to Dec 31, 9999 0:00:00 to 23:59:59 True or False one Unicode character

2 4 8

No No No

Yes
Decimal

16 8 2 2

Yes

Do you need to do math with the data?

No

Use the String data type (Zip codes, phone numbers, etc.)

Date Boolean Character

Yes

Data Type
Short

Prefix
sho

Does this data have to be a whole number (people, # of items, etc.)?

No

Use the Decimal data type

Integer Long String

int lng str dec dat bln or bol chr

Yes

Decimal Date Boolean

Will the data be outside of the range of 0-255?

No

Use the Byte data type

Character

Variable Declaration
Yes

Dim varName As Type - Where varName is the variable and Type is the data type -Substitute the name of your variable for varName and change Type to the data type for the variable
Use the Integer data type

Will the data be outside of the range of -32,768 to 32,767?

No

Use the Short data type

Yes

Will the data be outside of the range of -2,147,483,648 to 2,147,483,647

No

Constant Declaration
Const SALES_TAX_RATE As Decimal = 0.05 - Const creates a constant that cant be changed - Reserves memory for SALES_TAX_RATE - Declared as a Decimal - Assigns value of 0.05 NOTE: All caps coding standard is different than book - SALES_TAX_RATE cannot changed at runtime - Value can only be changed by changing this line - You MUST give a constant a value when you declare it

Yes

Use the Long data type

You might also like