Вы находитесь на странице: 1из 55

Toolbox

Office 2007

Displays the standard Visual Basic controls plus any ActiveX controls and insertable objects you have
added to your project.

You can customize the Toolbox by adding pages to it or by adding controls using
the Additional Controls command from the Tools menu.

When you add a page, a Select Objects tool is always available on the page.
Standard Toolbox Controls

Select Objects
Select Objects is the only item in the Toolbox that doesn't draw a control. When you select it, you can
only resize or move a control that has already been drawn on a form.

Label
Allows you to have text that you do not want the user to change, such as a caption under a graphic.

TextBox
Holds text that the user can either enter or change.

ComboBox
Allows you to draw a combination list box and text box. The user can either choose an item from the list
or enter a value in the text box.

ListBox
Use to display a list of items from which the user can choose. The list can be scrolled if it has more items
than can be displayed at one time.

CheckBox
Creates a box that the user can easily choose to indicate if something is true or false, or to display
multiple choices when the user can choose more than one.

OptionButton
Allows you to display multiple choices from which the user can choose only one.

ToggleButton
Creates a button that toggles on and off.

Frame
Allows you to create a graphical or functional grouping for controls. To group controls, draw the frame
first, and then draw controls inside the frame.

CommandButton
Creates a button the user can choose to carry out a command.

TabStrip
Allows you to define multiple pages for the same area of a window or dialog box in your application.

MultiPage
Presents multiple screens of information as a single set.

ScrollBar
Provides a graphical tool for quickly navigating through a long list of items or a large amount of
information, for indicating the current position on a scale, or as an input device or indicator of speed or
quantity.

SpinButton
A spinner control you can use with another control to increment and decrement numbers. You can also
use it to scroll back and forth through a range of values or a list of items.

Image
Displays a graphical image from a bitmap, icon, or metafile on your form. Images displayed in
an Image control can only be decorative and use fewer resources than a PictureBox.
Breakpoint
Sets or removes a breakpoint at the current line.
Bookmark
Displays or removes a bookmark at the active line in the Code window.
This documentation is archived and is not being maintained.

VBE Glossary
Office 2007

access key
A key pressed while holding down the ALT key that allows the user to open a menu, carry out a command,
select an object, or move to an object. For example, ALT+F opens the File menu.
ActiveX control
An object that you place on a form to enable or enhance a user's interaction with an application. ActiveX
Controls have events and can be incorporated into other controls. These controls have an .ocx file name
extension.
ActiveX object
An object that is exposed to other applications or programming tools through Automation interfaces.
add-in
A customized tool that adds capabilities to the Visual Basic development environment.
ANSI Character Set
American National Standards Institute (ANSI) 8-bit character set used to represent up to 256 characters
(0255) using your keyboard. The first 128 characters (0127) correspond to the letters and symbols on a
standard U.S. keyboard. The second 128 characters (128255) represent special characters, such as letters
in international alphabets, accents, currency symbols, and fractions.
application
A collection of code and visual elements that work together as a single program. Developers can build
and run applications within the development environment, while users usually run applications as
executable files outside the development environment.
argument
A constant, variable, or expression passed to a procedure.
array
A set of sequentially indexed elements having the same intrinsic data type. Each element of an array has a
unique identifying index number. Changes made to one element of an array don't affect the other
elements.
ASCII Character Set
American Standard Code for Information Interchange (ASCII) 7-bit character set used to represent letters
and symbols found on a standard U.S. keyboard. The ASCII character set is the same as the first 128
characters (0127) in the ANSI character set.
automatic formatting
A feature that automatically formats code as you enter it by capitalizing the first letter for keywords,
standardizing spacing, adding punctuation, and setting the foreground and background colors.
base class
Original class from which other classes can be derived by inheritance.
bitmap
An image represented by pixels and stored as a collection of bits in which each bit corresponds to one
pixel. On color systems, more than one bit corresponds to each pixel. A bitmap usually has a .bmp file
name extension.
bitwise comparison
A bit-by-bit comparison between identically positioned bits in two numeric expressions.
Boolean expression
An expression that evaluates to either True or False.
Boolean data type
A data type with only two possible values, True (-1) or False (0). Boolean variables are stored as 16-bit (2-
byte) numbers.
bound control
A data-aware control that can provide access to a specific field or fields in a database through
a Data control. A data-aware control is typically bound to a Data control through
its DataSource and DataField properties. When a Data control moves from one record to the next, all
bound controls connected to the Data control change to display data from fields in the current record.
When users change data in a bound control and then move to a different record, the changes are
automatically saved in the database.
break mode
Temporary suspension of program execution in the development environment. In break mode, you can
examine, debug, reset, step through, or continue program execution. You enter break mode when you:

Encounter a breakpoint during program execution.


Press CTRL+BREAK during program execution.
Encounter a Stop statement or untrapped run-time error during program execution.
Add a Break When True watch expression. Execution stops when the value of the watch changes
and evaluates to True.
Add a Break When Changed watch expression. Execution stops when the value of the watch
changes.

breakpoint
A selected program line at which execution automatically stops. Breakpoints are not saved with your code.
by reference
A way of passing the address of an argument to a procedure instead of passing the value. This allows the
procedure to access the actual variable. As a result, the variable's actual value can be changed by the
procedure to which it is passed. Unless otherwise specified, arguments are passed by reference.
Byte data type
A data type used to hold positive integer numbers ranging from 0255. Byte variables are stored as single,
unsigned 8-bit (1-byte) numbers.
by value
A way of passing the value of an argument to a procedure instead of passing the address. This allows the
procedure to access a copy of the variable. As a result, the variable's actual value can't be changed by the
procedure to which it is passed.
character code
A number that represents a particular character in a set, such as the ANSI character set.
class
The formal definition of an object. The class acts as the template from which an instance of an object is
created at run time. The class defines the properties of the object and the methods used to control the
object's behavior.
class module
A module that contains the definition of a class, including its property and method definitions.
code module
A module containing public code that can be shared among all modules in a project. A code module is
referred to as a standard module in later versions of Visual Basic.
code pane
A pane contained in a code window that is used for entering and editing code. A code window can
contain one or more code panes.
collection
An object that contains a set of related objects. An object's position in the collection can change
whenever a change occurs in the collection; therefore, the position of any specific object in the collection
can vary.
command line
The path, file name, and argument information provided by the user to run a program.
comment
Text added to code that explains how the code works. In Visual Basic, a comment line can start with either
an apostrophe (') or with the Rem keyword followed by a space.
comparison operator
A character or symbol indicating a relationship between two or more values or expressions. These
operators include less than (<), less than or equal to (<=), greater than (>), greater than or equal to (>=),
not equal (<>), and equal (=). Additional comparison operators include Is and Like. Note
that Is and Like can't be used as comparison operators in a Select Case statement.
compiler directive
A command used to alter the action of the compiler.
compile time
The period during which source code is translated to executable code.
conditional compiler constant
A Visual Basic identifier that is defined using the #Const compiler directive or defined in the host
application and used by other compiler directives to determine when or if certain blocks of Visual Basic
code are compiled.
constant
A named item that retains a constant value throughout the execution of a program. A constant can be a
string or numeric literal, another constant, or any combination that includes arithmetic or logical
operators except Is and exponentiation. Each host application can define its own set of constants.
Additional constants can be defined by the user with the Const statement. You can use constants
anywhere in your code in place of actual values.
container
An object that can contain other objects.
control
An object you can place on a form that has its own set of recognized properties, methods, and events.
You use controls to receive user input, display output, and trigger event procedures. You can manipulate
most controls using methods. Some controls are interactive (responsive to user actions), while others are
static (accessible only through code).
control array
A group of controls that share a common name, type, and event procedures. Each control in an array has
a unique index number that can be used to determine which control recognizes an event.
Currency data type
A data type with a range of -922,337,203,685,477.5808 to 922,337,203,685,477.5807. Use this data type for
calculations involving money and for fixed-point calculations where accuracy is particularly important. The
at sign (@) type-declaration character represents Currency in Visual Basic.
data type
The characteristic of a variable that determines what kind of data it can hold. Data types
include Byte, Boolean, Integer, Long, Currency, Decimal, Single, Double, Date, String, Object, Variant
(default), and user-defined types, as well as specific types of objects.
Date data type
A data type used to store dates and times as a real number. Date variables are stored as 64-bit (8-byte)
numbers. The value to the left of the decimal represents a date, and the value to the right of the decimal
represents a time.
date expression
Any expression that can be interpreted as a date, including date literals, numbers that look like dates,
strings that look like dates, and dates returned from functions. A date expression is limited to numbers or
strings, in any combination, that can represent a date from January 1, 100 December 31, 9999.
Dates are stored as part of a real number. Values to the left of the decimal represent the date; values to
the right of the decimal represent the time. Negative numbers represent dates prior to December 30,
1899.
date literal
Any sequence of characters with a valid format that is surrounded by number signs (#). Valid formats
include the date format specified by the locale settings for your code or the universal date format.
For example,
#12/31/92#

is the date literal that represents December 31, 1992, where English-U.S. is the locale setting for your
application. Use date literals to maximize portability across national languages.
date separators
Characters used to separate the day, month, and year when date values are formatted. The characters are
determined by system settings or by the Format function.
DBCS
A character set that uses 1 or 2 bytes to represent a character, allowing more than 256 characters to be
represented.
dynamic data exchange (DDE)
An established protocol for exchanging data through active links between applications that run under
Microsoft Windows.
Decimal data type
A data type that contains decimal numbers scaled by a power of 10. For zero-scaled numbers, that is,
numbers with no decimal places, the range is +/-79,228,162,514,264,337,593,543,950,335. For numbers
with 28 decimal places the range is +/-7.9228162514264337593543950335. The smallest non-zero
number that can be represented as a Decimal is 0.0000000000000000000000000001.
Note that at this time the Decimal data type can only be used within a Variant. You cannot declare a
variable to be of type Decimal. You can, however, create a Variant whose subtype is Decimal using
the CDec function.
declaration
Nonexecutable code that names a constant, variable, or procedure, and specifies its characteristics, such
as data type. For DLL procedures, declarations specify names, libraries, and arguments.
designer
Provides a visual design window in the Visual Basic development environment. You can use this window
to design new classes visually. Visual Basic has built-in designers for forms. The Professional and
Enterprise editions of Visual Basic include designers for ActiveX controls and ActiveX documents.
design time
The time during which you build an application in the development environment by adding controls,
setting control or form properties, and so on. In contrast, during run time, you interact with the
application like a user.
development environment
The part of the application where you write code, create controls, set control and form properties, and so
on. This contrasts with running the application.
dynamic-link library (DLL)
A library of routines loaded and linked into applications at run time. DLLs are created with other
programming languages such as C, MASM, or FORTRAN.
docked window
A window that is attached to the frame of the main window.
document
Any self-contained work created with an application and given a unique file name.
Double data type
A data type that holds double-precision floating-point numbers as 64-bit numbers in the range -
1.79769313486231E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to
1.79769313486232E308 for positive values. The number sign (#) type-declaration character represents
the Double in Visual Basic.
Empty
Indicates that no beginning value has been assigned to a Variant variable. An Empty variable is
represented as 0 in a numeric context or a zero-length string ("") in a string context.
error number
A whole number in the range 0 65,535 that corresponds to the Number property setting of
the Err object. When combined with the Description property setting of the Err object, this number
represents a particular error message.
event source object
An object that is the source of events that occur in response to an action. An event source object is
returned by a property. For example, the CommandBarEvents property returns
the CommandBarEvents object.
executable file
A Windows-based application that can run outside the development environment. An executable file has
an .exe file name extension.
expression
A combination of keywords, operators, variables, and constants that yields a string, number, or object. An
expression can be used to perform a calculation, manipulate characters, or test data.
file number
Number used in the Open statement to open a file. Use file numbers in the range 1255, inclusive, for files
not accessible to other applications. Use file numbers in the range 256511 for files accessible from other
applications.
focus
The ability to receive mouse clicks or keyboard input at any one time. In the Microsoft Windows
environment, only one window, form, or control can have this ability at a time. The object that "has the
focus" is normally indicated by a highlighted caption or title bar. The focus can be set by the user or by
the application.
form
A window or dialog box. Forms are containers for controls. A multiple-document interface (MDI) form can
also act as a container for child forms and some controls.
form module
A file in a Visual Basic project with an .frm file name extension that can contain graphical descriptions of a
form; its controls and their property settings; form-level declarations of constants, variables, and external
procedures; and event and general procedures.
Function procedure
A procedure that performs a specific task within a program and returns a value. A Function procedure
begins with a Function statement and ends with an End Function statement.
general procedure
A procedure that must be explicitly called by another procedure. In contrast, an event procedure is
invoked automatically in response to a user or system action.
graphics method
A method that operates on an object such as a Form, PictureBox, or Printer, and performs run-time
drawing operations such as animation or simulation. The graphics methods
are Circle, Cls, Line, PaintPicture, Point, Print, and PSet.
host application
Any application that supports the use of Visual Basic for Applications, for example, Microsoft Excel,
Microsoft Project, and so on.
icon
A graphical representation of an object or concept; commonly used to represent minimized applications
in Microsoft Windows. An icon is a bitmap with a maximum size of 32 x 32 pixels. Icons have an .ico file
name extension.
identifier
An element of an expression that refers to a constant or variable.
in process
Running in the same address space as an application.
insertable object
An application object that is a type of custom control, such as a Microsoft Excel worksheet.
Integer data type
A data type that holds integer variables stored as 2-byte whole numbers in the range -32,768 to 32,767.
The Integer data type is also used to represent enumerated values. The percent sign (%) type-declaration
character represents an Integer in Visual Basic.
intrinsic constants
A constant provided by an application. Visual Basic constants are listed in the object library and can be
viewed with the Object Browser. Because you can't disable intrinsic constants, you can't create a user-
defined constant with the same name.
keyword
A word or symbol recognized as part of the Visual Basic programming language; for example, a
statement, function name, or operator.
line-continuation character
The combination of a space followed by an underscore ( _) used in the development environment to
extend a single logical line of code to two or more physical lines. However, you can't use a line-
continuation character to continue a line of code within a string expression.
line label
Used to identify a single line of code. A line label can be any combination of characters that starts with a
letter and ends with a colon (:). Line labels are not case sensitive and must begin in the first column.
line number
Used to identify a single line of code. A line number can be any combination of digits that is unique within
the module where it is used. Line numbers must begin in the first column.
linked window
A window that is joined to another window other than the main window.
linked window frame
A window frame containing multiple windows that have been linked together.
locale
The set of information that corresponds to a given language and country. The code locale setting affects
the language of terms such as keywords and defines locale-specific settings such as the decimal and list
separators, date formats, and character sorting order.
The system locale setting affects the way locale-aware functionality behaves, for example, when you
display numbers or convert strings to dates. You set the system locale using the Control Panel utilities
provided by the operating system.
Although the code locale and system locale are generally set to the same setting, they may differ in some
situations. For example, in Visual Basic, Standard Edition and Visual Basic, Professional Edition, the code is
not translated from English-U.S. The system locale can be set to the user's language and country, but the
code locale is always set to English-U.S. and can't be changed. In this case, the English-U.S. separators,
format placeholders, and sorting order are used.
logic error
A programming error that can cause code to produce incorrect results or stop execution. For example, a
logic error can be caused by incorrect variable names, incorrect variable types, endless loops, flaws in
comparisons, or array problems.
Long data type
A 4-byte integer ranging in value from -2,147,483,648 to 2,147,483,647. The ampersand (&) type-
declaration character represents a Long in Visual Basic.
margin indicator
An icon displayed in the Margin Indicator bar in the Code window. Margin indicators provide visual cues
during code editing.
MDI child
A form contained within an MDI form in a multiple-document interface (MDI) application. To create a
child form, set the MDIChild property of the MDI form to True.
MDI form
A window that makes up the background of a multiple-document interface (MDI) application. The MDI
form is the container for any MDI child forms in the application.
member
An element of a collection, object, or user-defined type.
metafile
A file that stores an image as graphical objects such as lines, circles, and polygons rather than as pixels.
There are two types of metafiles, standard and enhanced. Standard metafiles usually have a .wmf file
name extension. Enhanced metafiles usually have a .emf file name extension. Metafiles preserve an image
more accurately than pixels when the image is resized.
method
A procedure that acts on an object.
module
A set of declarations followed by procedures.
module level
Describes code in the Declarations section of a module. Any code outside a procedure is referred to as
module-level code. Declarations must be listed first, followed by procedures.
module variable
A variable declared outside Function, Sub, or Property procedure code. Module variables must be
declared outside any procedures in the module. They exist while the module is loaded and are visible in all
procedures in the module.
named argument
An argument that has a name that is predefined in the object library. Instead of providing a value for each
argument in a specified order expected by the syntax, you can use named arguments to assign values in
any order. For example, suppose a method accepts three arguments:
DoSomeThing namedarg1, namedarg2, namedarg3
By assigning values to named arguments, you can use the following statement:
DoSomeThing namedarg3 := 4, namedarg2 := 5, namedarg1 := 20

Note that the named arguments don't have to appear in the normal positional order in the syntax.
Null
A value indicating that a variable contains no valid data. Null is the result of an explicit assignment
of Null to a variable or any operation between expressions that contain Null.
numeric data type
Any intrinsic numeric data type (Byte, Boolean, Integer, Long, Currency, Single, Double, or Date).
numeric expression
Any expression that can be evaluated as a number. Elements of an expression can include any
combination of keywords, variables, constants, and operators that result in a number.
numeric type
Any intrinsic numeric data type (Byte, Boolean, Integer, Long, Currency, Single, Double, or Date) or
any Variant numeric subtype
(Empty, Integer, Long, Single, Double, Currency, Decimal, Date, Error, Boolean, or Byte).
object
A combination of code and data that can be treated as a unit, for example, a control, form, or application
component. Each object is defined by a class.
Object box
A list box at the upper-left corner of the Code window that lists the form and controls in the form to
which the code is attached, or a list box located at the top of the Properties window that lists the form
and its controls.
Object Browser
A dialog box in which you can examine the contents of an object library to get information about the
objects provided.
Object data type
A data type that represents any Object reference. Object variables are stored as 32-bit (4-byte) addresses
that refer to objects.
object expression
An expression that specifies a particular object and can include any of the object's containers. For
example, an application can have an Application object that contains a Document object that contains
a Text object.
object library
A file with the .olb extension that provides information to Automation controllers (like Visual Basic) about
available objects. You can use the Object Browser to examine the contents of an object library to get
information about the objects provided.
object module
A module that contains code specific to an object, for example, class module, form module, and
document module. Object modules contain the code behind their associated objects. The rules for object
modules differ from those for standard modules.
object type
A type of object exposed by an application through Automation, for example, Application, File, Range,
and Sheet. Use the Object Browser or refer to the application's documentation for a complete listing of
available objects.
object variable
A variable that contains a reference to an object.
Automation object
An object that is exposed to other applications or programming tools through Automation interfaces.
parameter
Variable name by which an argument passed to a procedure is known within the procedure. This variable
receives the argument passed into the procedure. Its scope ends when the procedure ends.
path
A string expression specifying a directory or folder location. The location can include a drive specification.
pi
A mathematical constant equal to approximately 3.1415926535897932.
point
A point is 1/72 inch. Font sizes are usually measured in points.
print zone
Print zones begin every 14 columns. The width of each column is an average of the width of all characters
in the point size for the selected font.
Private
Variables that are visible only to the module in which they are declared.
procedure
A named sequence of statements executed as a unit. For example, Function, Property, and Sub are types
of procedures. A procedure name is always defined at module level. All executable code must be
contained in a procedure. Procedures can't be nested within other procedures.
Procedure box
A list box at the upper-right corner of the Code window and the Debug window that displays the
procedures recognized for the object displayed in the Object box.
procedure call
A statement in code that tells Visual Basic to execute a procedure.
procedure level
Describes statements located within a Function, Property, or Sub procedure. Declarations are usually
listed first, followed by assignments and other executable code.
Note that module-level code resides outside a procedure block.
project
A set of modules.
Project window
A window that displays a list of the form, class, and standard modules; the resource file; and references in
your project. Files with .ocx and .vbx file name extensions aren't displayed in the Project window.
Properties window
A window used to display or change properties of a selected form or control at design time. Some custom
controls have customized Properties windows.
property
A named attribute of an object. Properties define object characteristics such as size, color, and screen
location, or the state of an object, such as enabled or disabled.
Property procedure
A procedure that creates and manipulates properties for a class module. A Property procedure begins
with a Property Let, Property Get, or Property Set statement and ends with an End Property statement.
Public
Variables declared using the Public statement are visible to all procedures in all modules in all
applications unless Option Private Module is in effect. In that case, the variables are public only within
the project in which they reside.
referenced project
The project you directly create a link to from the current project you are working on. A project referenced
by one of the current project's directly referenced projects is called an indirectly referenced project.
Its Public variables are not accessible to the current project except through qualification with its project
name. Any combination of direct and indirect references between projects is valid as long as they do not
result in a complete cycle.
referencing project
The current project. How you create a link to a project depends on the host application. For example, to
directly reference a project in Microsoft Excel, select the project from the References dialog box of
the Tools menu. Public variables in a directly referenced project are visible to the directly referencing
project, but Public variables in a directly referencing project are not visible to a directly referenced
project.
registry
In Microsoft Windows version 3.1, OLE registration information and file associations are stored in the
registration database, and program settings are stored in Windows system initialization (.ini) files. In
Microsoft Windows 95, the Windows registry serves as a central configuration database for user,
application, and computer-specific information, including the information previously contained in both
the Windows version 3.1 registration database and .ini files.
resource file
A file in a Visual Basic project with an .res file name extension that can contain bitmaps, text strings, or
other data. By storing this data in a separate file, you can change the information without editing your
code. Only one resource file can be associated with a project.
run-time error
An error that occurs when code is running. A run-time error results when a statement attempts an invalid
operation.
run time
The time during which code is running. During run time, you can't edit the code.
scope
Defines the visibility of a variable, procedure, or object. For example, a variable declared as Public is
visible to all procedures in all modules in a directly referencing project unless Option Private Module is
in effect. When Option Private Module is in effect, the module itself is private and therefore not visible
to referencing projects. Variables declared in a procedure are visible only within the procedure and lose
their value between calls unless they are declared Static.
seed
An initial value used to generate pseudorandom numbers. For example, the Randomize statement
creates a seed number used by the Rnd function to create unique pseudorandom number sequences.
Single data type
A data type that stores single-precision floating-point variables as 32-bit (4-byte) floating-point numbers,
ranging in value from -3.402823E38 to -1.401298E-45 for negative values, and 1.401298E-45 to
3.402823E38 for positive values. The exclamation point (!) type-declaration character represents
a Single in Visual Basic.
sort order
A sequencing principle used to order data, for example, alphabetic, numeric, ascending, descending, and
so on.
stack
A fixed amount of memory used by Visual Basic to preserve local variables and arguments during
procedure calls.
standard module
A module containing only procedure, type, and data declarations and definitions. Module-level
declarations and definitions in a standard module are Public by default. A standard module is referred to
as a code module in earlier versions of Visual Basic.
statement
A syntactically complete unit that expresses one kind of action, declaration, or definition. A statement
generally occupies a single line, although you can use a colon (:) to include more than one statement on a
line. You can also use a line-continuation character (_) to continue a single logical line onto a second
physical line.
string comparison
A comparison of two sequences of characters. Use Option Compare to specify binary or text comparison.
In English-U.S., binary comparisons are case sensitive; text comparisons are not.
string constant
Any constant (defined using the Const keyword) consisting of a sequence of contiguous characters
interpreted as the characters themselves rather than as a numeric value.
String data type
A data type consisting of a sequence of contiguous characters that represent the characters themselves
rather than their numeric values. A String can include letters, numbers, spaces, and punctuation.
The String data type can store fixed-length strings ranging in length from 0 to approximately 63K
characters and dynamic strings ranging in length from 0 to approximately 2 billion characters. The dollar
sign ($) type-declaration character represents a String in Visual Basic.
string expression
Any expression that evaluates to a sequence of contiguous characters. Elements of a string expression can
include a function that returns a string, a string literal, a string constant, a string variable, a string Variant,
or a function that returns a string Variant (VarType 8).
string literal
Any expression consisting of a sequence of contiguous characters surrounded by quotation marks that is
literally interpreted as the characters within the quotation marks.
Sub procedure
A procedure that performs a specific task within a program, but returns no explicit value. A Sub procedure
begins with a Sub statement and ends with an End Sub statement.
syntax checking
A feature that checks your code for correct syntax. If the syntax checking feature is enabled, a message is
displayed when you enter code that contains a syntax error and the suspect code is highlighted.
syntax error
An error that occurs when you enter a line of code that Visual Basic doesn't recognize.
Note that syntax rules for individual keywords are defined in the Syntax section of the associated Help
topic. To get Help on a keyword from within the development environment, select the keyword and press
F1.
tab order
The order in which the focus moves from one field to the next as you press TAB or SHIFT+TAB.
time expression
Any expression that can be interpreted as a time. This includes any combination of time literals, numbers
that look like times, strings that look like times, and times returned from functions.
Times are stored as part of a real number. Values to the right of the decimal represent the time. For
example, midday (12:00 P.M.) is represented by 0.5.
twip
A unit of screen measurement equal to 1/20 point. A twip is a screen-independent unit used to ensure
that placement and proportion of screen elements in your screen application are the same on all display
systems. There are approximately 1440 twips to a logical inch or 567 twips to a logical centimeter (the
length of a screen item measuring one inch or one centimeter when printed).
type-declaration character
A character appended to a variable name indicating the variable's data type. By default, variables are of
type Variant unless a corresponding Deftype statement is present in the module.
type library
A file or component within another file that contains standard descriptions of exposed objects, properties,
and methods that are available for Automation. Object library files (.olb) contain type libraries.
Unicode
International Standards Organization (ISO) character standard. Unicode uses a 16-bit (2-byte) coding
scheme that allows for 65,536 distinct character spaces. Unicode includes representations for punctuation
marks, mathematical symbols, and dingbats, with substantial room for future expansion.
universal date format
The universal date format is
#yyyy-mm-dd hh:mm:ss#

. However, both the date component (


#yyyy-mm-dd#

) and the time component (


#hh:mm:ss#

) can be represented separately.


user-defined type
Any data type defined using the Type statement. User-defined data types can contain one or more
elements of any data type. Arrays of user-defined and other data types are created using
the Dim statement. Arrays of any type can be included within user-defined types.
variable
A named storage location that can contain data that can be modified during program execution. Each
variable has a name that uniquely identifies it within its scope. A data type can be specified or not.
Variable names must begin with an alphabetic character, must be unique within the same scope, can't be
longer than 255 characters, and can't contain an embedded period or type-declaration character.
Variant data type
A special data type that can contain numeric, string, or date data as well as user-defined types and the
special values Empty and Null. The Variant data type has a numeric storage size of 16 bytes and can
contain data up to the range of a Decimal, or a character storage size of 22 bytes (plus string length), and
can store any character text. The VarType function defines how the data in a Variant is treated. All
variables become Variant data types if not explicitly declared as some other data type.
variant expression
Any expression that can evaluate to numeric, string, or date data, as well as the special
values Empty and Null.
watch expression
A user-defined expression that enables you to observe the behavior of a variable or expression. Watch
expressions appear in the Watch window of the Visual Basic Editor and are automatically updated when
you enter break mode. The Watch window displays the value of an expression within a given context.
Watch expressions are not saved with your code.
z-order
The visual layering of controls on a form along the form's z-axis (depth). The z-order determines which
controls are in front of other controls.
This documentation is archived and is not being maintained.

Toolbars Command (View Menu)


Office 2007

Lists the toolbars that are built into Visual Basic and the Customize command. You can:

Toggle the toolbars on and off.


Drag the toolbars to different locations on you desktop.

Debug
Displays the Debug toolbar which contains buttons for common debugging tasks.
Edit
Displays the Edit toolbar which contains buttons for common editing tasks.
Standard
Displays the Standard toolbar which is the default toolbar.
UserForm
Displays the UserForm toolbar which contains buttons specific to the form.
Customize
Displays the Customize dialog box where you can customize or create toolbars and your menu bar.

Toolbars Tab (Customize Dialog


Box)
Office 2007

Allows you to create, rename, delete, and reset your toolbars,


Tab Options
Toolbars box
Displays the toolbars built into Visual Basic and any toolbars you create. When you show a toolbar, a
check mark appears to the left of it.

Note

The Menu bar cannot be hidden. It can only be reset.

New
Opens the New Toolbar dialog box where you type the name for your new toolbar in the Toolbar Name
box.
Rename
Opens the Rename Toolbar dialog box where you type the new name for your toolbar. Only available if
you select a user-defined toolbar.
Delete
Deletes a user-defined toolbar from your project. Only available if you select a user-defined toolbar.
Reset
Removes any changes to the built-in toolbars and resets them to their original state. Only available if you
select a built-in toolbar.

UserForm Command Bar


Office 2007

Contains buttons that are shortcuts to some commonly used menu items that are useful for working with
forms.
You can click a toolbar button once to carry out the action represented by that button. You can select the
Show ToolTips option in the General tab of the Options dialog box if you want to display ToolTips for the
toolbar buttons.
Toolbar Buttons
Bring To Front
Moves the selected objects to the front of all other objects on a form.
Send To Back
Moves the selected objects behind all other objects on a form.
Group
Creates a group of the selected objects.
Ungroup
Ungroups the objects that were previously grouped.
Align

Lefts Aligns the horizontal position of the selected objects, putting the left-most edges in
line.
Centers Aligns the horizontal position of the selected objects, putting the centers in line.
Rights Aligns the horizontal position of the selected objects, putting the right-most edges
in line.
Tops Aligns the vertical position of the selected objects, putting the tops in line.
Middles Aligns the vertical position of selected objects, putting the middles in line.
Bottoms Aligns the vertical position of the selected objects, putting the bottoms in line.
to Grid Aligns the top left of the selected object to the closest grid. The object is not
resized.

Center

Horizontally Centers the selected objects horizontally.


Vertically Centers the selected objects vertically.

Make Same Size

Width Adjusts width.


Height Adjusts height.
Both Adjusts both the width and the height.

Zoom
Reduces or enlarges the display of all controls on the UserForm. You can set any magnification between
10 and 400 percent.

UserForm Window
Office 2007
Allows you to create the windows or dialog boxes in your project. You draw and view controls on a form.
While you are designing a form:

Each form window has a Maximize, Minimize, and Close button.


You can view the form grid and determine the size of the gridlines from the General tab of
the Options dialog box.
Use the buttons in the Toolbox to draw controls on the form. You can set your controls to align
with the grid of your form from the General tab of the Options dialog box.

UserForm Window Keys


Office 2007

Use these key combinations in the UserForm window:

Press To

SHIFT+CTRL +ALPHA Select a property in the Property list of the Properties window.

ALPHA Enter a value in the Properties window for the selected property.

F7 Open the Code window for the selected object.


DEL or DELETE Delete the selected controls without placing them on the Clipboard.

CTRL+Z Undo a deletion of controls.

TAB Cycle forward through controls in tab order.

SHIFT+TAB Cycle backward through controls in tab order.

CTRL+CLICK Add or remove a control from the selection.

CLICK+DRAG Select multiple controls.

SHIFT+CLICK Select multiple controls.

CTRL+CLICK+DRAG Add or remove controls from the current selection.

F6 Display the Properties window (design time only).

SHIFT+F10 View shortcut.


CTRL+J Bring to front (affects overlapping controls at design time only).

CTRL+K Send to back (affects overlapping controls at design time only).

To deselect all controls, click the form. To select controls in a container, first deselect the
container and then CTRL+CLICK+DRAGaround the desired controls.
This documentation is archived and is not being maintained.

Vertical Spacing Commands


(Format Menu)
Office 2007

Changes the vertical space between the selected objects, based on the object with focus. When
an object has focus, white handles appear on its borders.
Make Equal
Moves the selected objects so that there is equal space between them using the top and bottom
objects as the endpoints.
Toolbar shortcut: .
Increase
Increases the vertical spacing by one grid based on the object with focus. You can change the size
of your grid units in the General tab of the Options dialog box.
Toolbar shortcut: .
Decrease
Decreases the vertical spacing by one grid based on the object with focus. You can change the
size of your grid units in the General tab of the Options dialog box.
Toolbar shortcut: .
Remove
Removes the vertical spacing so that the objects borders are touching, based on the object with
focus
Toolbar shortcut: .
Watch Window Keyboard
Shortcuts
Office 2007

Use these key combinations in the Watch window:

Press To

SHIFT+ENTER Display the selected watch expression.

CTRL+W Display Edit Watch dialog box.

ENTER Expands or collapses the selected watch value if it has a plus (+) or minus (-)
to the left of it.

F2 Display the Object Browser.

SHIFT+F10 View shortcut menu.

Window Menu Commands


Office 2007
Split
Toggles splitting the Code window in half horizontally. Only available when the Code window is active.
Toolbar shortcut: .
Tile Horizontally
Tiles all open document windows in your project horizontally.
Toolbar shortcut: .
Tile Vertically
Tiles all open document windows in your project vertically.
Toolbar shortcut: .
Cascade
Rearranges all open document windows in your project so they overlap in a cascade.
Toolbar shortcut: .
Arrange Icons
Arranges the icons of any document windows you have minimized, neatly at the bottom left of the
window.
Window List
Lists all open document windows.

Zoom Command
Office 2007

Reduces or enlarges the display of the selected form. You can choose or type a magnification between 10
and 400 percent.
Only available on theUserForm toolbar.

Toolbar:

Add Watch Command (Debug


Menu)
Office 2007

Displays the Add Watch dialog box in which you enter a watch expression. The expression can be any
valid Basic expression. Watch expressions are updated in the Watch window each time you enter break
mode.
Toolbar shortcut: .

Add Watch Command (Debug


Menu)
Office 2007

Displays the Add Watch dialog box in which you enter a watch expression. The expression can be any
valid Basic expression. Watch expressions are updated in the Watch window each time you enter break
mode.

Toolbar shortcut: .

Add Watch Dialog Box


Office 2007

Use to enter a watch expression. The expression can be a variable, a property, a function call, or any other
valid Basic expression. Watch expressions are updated in the Watch window each time you enter break
mode or after execution of each statement in the Immediate window.
You can drag selected expressions from the Code window into the Watch window.
Important When selecting a context for a watch expression, use the narrowest scope that fits your
needs. Selecting all procedures or all modules could slow down execution considerably, since the
expression is evaluated after execution of each statement. Selecting a specific procedure for a context
affects execution only while the procedure is in the list of active procedure calls, which you can see by
choosing the Call Stack command on the View menu.
Dialog Box Options
Expression
Displays the selected expression by default. The expression is a variable, a property, a function call, or any
other valid expression. You may enter a different expression to evaluate.
Context
Sets the scope of the variables watched in the expression.

Procedure Displays the procedure name where the selected term resides (default). Defines the
procedure(s) in which the expression is evaluated. You may select all procedures or a specific
procedure context in which to evaluate the variable.
Module Displays the module name where the selected term resides (default). You may select
all modules or a specific module context in which to evaluate the variable.
Project Displays the name of the current project. Expressions can't be evaluated in a context
outside of the current project.

Watch Type
Determines how Visual Basic responds to the watch expression.

Watch Expression Displays the watch expression and its value in the Watch window. When you
enter break mode, the value of the watch expression is automatically updated.
Break When Value Is True Execution automatically enters break mode when the expression
evaluates to true or is any nonzero value (not valid for string expressions).
Break When Value Changes Execution automatically enters break mode when the value of
expression changes within the specified context.

Label (control)
From Wikipedia, the free encyclopedia


Labels being used to indicate the purpose of a spinner box, as well as for a category heading.

A label is a graphical control element which displays text on a form. It is usually a static
control; having no interactivity. A label is generally used to identify a nearby text box or
other widget.[1] Some labels can respond to events such as mouse clicks, allowing the text of
the label to be copied, but this is not standard user-interface practice. Labels usually cannot
be given the focus, although in applications written in Java using the Swing toolkit, labels can
be focused through tabbing[citation needed]. By contrast, in native Microsoft Windows applications,
labels cannot be focused by this method.
There is also a similar control known as a link label. Unlike a standard label, a link label
looks and acts like a hyperlink, and can be selected and activated.[2] This control may have
features such as changing colour when clicked or hovered over.
Difference between listbox and combo box.
List Box :
1. Occupies more space but shows more than one value.
2. We can select multiple items.
3. we can use checkboxes with in the list box.

Combo Box:

1. Occupies less space but shows only one value for visibility
2. Multiple select is not possible
3. can't use checkboxes within combo boxes

Combo Box
1) It is Combination of TextBox and ListBox
2) Three Styles (i)Simple combo (ii) DropDown (iii) DropDown List
The main Difference between listbox and combo box.We cann't write any thing on the listbox but Combo
box we can write.
Listbox:
1) Does not contain a text box to write an item, Item is added using Additem method only

2) Always shows all item in the list


3) Can contain a checkbox in the list

ComboBox:

1) Can contain a text box to write an item, Item is added also using Additem method only

2) Style property define if the item in the list have to be always shown
3) No checkbox is used
we can select Multiple option in Listbox whereas only one option we can select from the collection of data
in Combobox..
list box:
1)does not contain a text box to write an item.
2)always shows more than one item.
3)we can select one item from multiple items in the list box.
4)contain a check box with in the list box.

combo box:
1)contain a text box.
2)always shows one item.
3)selection is not available.
4)does not contain a checkbox.
Listbox is a tool provided by visual basic that list the number of items in a specific manner and provides a
facility to select one of the entry from the list only using drop down list,there are some extensions to
listbox like Dir listbox,File listbox,etc.
Combobox is a combination of textbox and listbox,i.e,you can select the one of the required entity from
the list either by typing in the box or by using drop down list.
It is easy to understand and simple to calculate.
Listbox :- The list box is a list of items that a user can choose from.
combobox :- The combobox is a combines a text box with a list box.
List box contain a list of item and allow you to select multiple item. While Combo box contain a list of
drop down box and allow you to select only single item.
Listbox has multiple item to choose from while combobox provides a text box with a listbox so that user
can also give input incase required

Text box
From Wikipedia, the free encyclopedia
This page is about boxes where text is entered in computing. For the help page on creating a simple
HTML form on Wikipedia, using wiki syntax, see Help:Inputbox. For infoboxes in Wikipedia, where
text is displayed and not entered, see Template:Infobox and Wikipedia:Infobox.

This article does not cite any sources. Please help improve this
article by adding citations to reliable sources. Unsourced material may be
challenged and removed. (February 2017) (Learn how and when to remove this template
message)

A text entry box

A text box in a text processing program.

A text box, text field or text entry box is a graphical control element intended to enable the user to
input text information to be used by the program. Human Interface Guidelines recommend a single-
line text box when only one line of input is required, and a multi-line text box only if more than one
line of input may be required. Non-editable text boxes can serve the purpose of simply displaying
text.
A typical text box is a rectangle of any size, possibly with a border that separates the text box from
the rest of the interface. Text boxes may contain zero, one, or two scrollbars. Text boxes usually
display a text cursor (commonly a blinking vertical line), indicating the current region of text being
edited. It is common for the mouse cursor to change its shape when it hovers over a text box.
Standard functionality[edit]
Typical implementations allow a user to do the following:

Type in text using a keyboard


When keys are pressed, the text appears where the caret is. Some very simple text boxes
may not show a caret, which would suggest that new characters typed in will appear at the
end of the current text.
Navigate and select portions of text
Using a mouse:
Change the caret position by clicking the desired point with a mouse cursor;
Select a portion of text by pressing the main mouse button while pointing the cursor at
one end of the desired part of the text and dragging the cursor to the other end while
holding the button pressed.
Using the keyboard:
Pressing arrow keys changes caret position by one character or line (in multiline text
boxes);
Pressing Home/End keys (Microsoft's Windows OS) or Command-left arrow/Command-
right arrow (Apple's Mac OS) moves the caret to the beginning/end of the line;
Pressing Page Up/Down moves the caret a page (the number of lines that can be
displayed in the text box at a time) backward/forward (Windows) or moves
the scrollbar thumb a page backward/forward without changing the caret position (Mac
OS);
Holding the Ctrl key (Windows) while pressing arrow keys or Home/End keys makes the
caret move at larger steps - e.g. words or paragraphs or beginning/end of document;
Holding the Option key (Mac OS) while pressing arrows moves the caret whole words or
paragraphs;
Holding the Command key while pressing up or down arrows (Mac OS) or Holding the
Ctrl key while pressing home/end (Windows) moves the caret to the beginning or end of
the document;
Holding the shift key while changing the caret position with a mouse or keyboard selects
the text between the caret position from when shift was first pressed and its current
position.
Pressing Control-A|Ctrl+A (Windows) selects all text.
Edit the text (enable changing the text already entered)
Work in insert or overwrite mode, typically switched using Insert key. In insert mode if there
is a character to the right of the caret, the new character will be inserted before it, while in
overwrite mode typing a new character will replace (overwrite) the character to the right of
the caret position.
Typing in a text while some part of the text already entered is selected will replace the
selected text.
Delete/Backspace keys remove one character right/left of current caret position, while
pressing them together with the Ctrl or command key removes one word.
Edit the text using standard clipboard operations.
Undo/Redo changes with Ctrl+Z/Ctrl+Y (Windows) or command-Z/command-shift-Z (Mac OS)
The keys indicated relate to the text box widget in Microsoft Windows and Mac OS X; similar if not
identical keyboard bindings exist under the X Window System and other systems, and typically
follow the same scheme as Windows.
Built-in ActiveX Controls in Visual
Basic 6.0
Filed under ACTIVEX CONTROLS IN VISUAL BASIC 6.0, V.B 6.0

ActiveX Controls :
One of the most exciting feature of Visual Basic is the ActiveX.It is the technology developed by
Microsoft that defines a communication standard between applications.The ActiveX control exist
as separate files with a .ocx file name extension. These include controls that are available in all
editions of Visual Basic and those that are available only in the Professional and Enterprise
editions (such as Listview, Toolbar, Animation, and Tabbed Dialog).

Adding Built-in ActiveX Controls to the Toolbox:


1. From the Project Menu, choose Components.you can also right click on toolbox.A popup
menu is open select components.
2. A component dialogbox is open .Select the Microsoft windows common controls 6.0(SP6).

3. Then click on apply button .you can see some other components like Listview,

Toolbar, Animation, and Tabbed Dialog show on your toolbox. Click on close button.Use this
conrol as you want
To build an ActiveX control from scratch and compile it so that it is usable as a command button
or a listbox is in other projects, you write the ActiveX Control and then compile it to an OCX
file. The ocx file contains only the user controls that were part of the VB project you built it from
and no extra stuff like forms or full programs

List of Built-in ActiveX Contorls:


Visual basic 6.0 offers us many built -in activex Controls of which a few are listed and briefly
explained below.
Related Posts

MonthView Control in Visual Basic6.0


A MonthView control display the current month and lets the user scroll through othe month ...read more
ImageCombo Control in Visual Basic 6.0
The ImageCombo control contains a collection of ComboItem objects. A ComboItem object defines the various ...read more

Date/Time Picker Control in Visual Basic6.0


DateTimePicker is a ActiveX controls. The Date/Time Picker control allow the user to specify a ...read more

Data Type Storage Requirements


InnoDB Table Storage Requirements
NDB Table Storage Requirements
Numeric Type Storage Requirements
Date and Time Type Storage Requirements
String Type Storage Requirements
Spatial Type Storage Requirements
The storage requirements for table data on disk depend on several factors. Different storage engines
represent data types and store raw data differently. Table data might be compressed, either for a
column or an entire row, complicating the calculation of storage requirements for a table or column.

Despite differences in storage layout on disk, the internal MySQL APIs that communicate and
exchange information about table rows use a consistent data structure that applies across all
storage engines.

This section includes guidelines and information for the storage requirements for each data type
supported by MySQL, including the internal format and size for storage engines that use a fixed-size
representation for data types. Information is listed by category or storage engine.

The internal representation of a table has a maximum row size of 65,535 bytes, even if the storage
engine is capable of supporting larger rows. This figure excludes BLOB or TEXT columns, which
contribute only 9 to 12 bytes toward this size. For BLOB and TEXT data, the information is stored
internally in a different area of memory than the row buffer. Different storage engines handle the
allocation and storage of this data in different ways, according to the method they use for handling
the corresponding types. For more information, see Chapter 15, Alternative Storage Engines,
and Section C.10.4, Limits on Table Column Count and Row Size.
InnoDB Table Storage Requirements
See Section 14.8.1.2, The Physical Row Structure of an InnoDB Table for information about
storage requirements for InnoDB tables.
NDB Table Storage Requirements
Important
NDB tables use 4-byte alignment; all NDB data storage is done in multiples of 4 bytes. Thus, a column
value that would typically take 15 bytes requires 16 bytes in an NDB table. For example,
in NDB tables, the TINYINT,SMALLINT, MEDIUMINT, and INTEGER (INT) column types each require 4
bytes storage per record due to the alignment factor.
Each BIT(M) column takes M bits of storage space. Although an individual BIT column is not 4-byte
aligned, NDBreserves 4 bytes (32 bits) per row for the first 1-32 bits needed for BIT columns, then
another 4 bytes for bits 33-64, and so on.
While a NULL itself does not require any storage space, NDB reserves 4 bytes per row if the table
definition contains any columns defined as NULL, up to 32 NULL columns. (If an NDB Cluster table is
defined with more than 32 NULL columns up to 64 NULL columns, then 8 bytes per row are
reserved.)

Every table using the NDB storage engine requires a primary key; if you do not define a primary key,
a hidden primary key is created by NDB. This hidden primary key consumes 31-35 bytes per table
record.
You can use the ndb_size.pl Perl script to estimate NDB storage requirements. It connects to a
current MySQL (not NDB Cluster) database and creates a report on how much space that database
would require if it used the NDB storage engine. See Section 21.4.28, ndb_size.pl
NDBCLUSTER Size Requirement Estimator for more information.
Numeric Type Storage Requirements
Data Type Storage Required
TINYINT 1 byte
SMALLINT 2 bytes
MEDIUMINT 3 bytes
INT, INTEGER 4 bytes
BIGINT 8 bytes
FLOAT(p) 4 bytes if 0 <= p <= 24, 8 bytes if 25 <= p <= 53
FLOAT 4 bytes
DOUBLE [PRECISION], REAL 8 bytes
DECIMAL(M,D), NUMERIC(M,D) Varies; see following discussion
BIT(M) approximately (M+7)/8 bytes
Values for DECIMAL (and NUMERIC) columns are represented using a binary format that packs nine
decimal (base 10) digits into four bytes. Storage for the integer and fractional parts of each value are
determined separately. Each multiple of nine digits requires four bytes, and the leftover digits
require some fraction of four bytes. The storage required for excess digits is given by the following
table.
Leftover Digits Number of Bytes
0 0
1 1
2 1
3 2
4 2
5 3
6 3
7 4
8 4
Date and Time Type Storage Requirements
For TIME, DATETIME, and TIMESTAMP columns, the storage required for tables created before
MySQL 5.6.4 differs from tables created from 5.6.4 on. This is due to a change in 5.6.4 that permits
these types to have a fractional part, which requires from 0 to 3 bytes.
Data Type Storage Required Before MySQL 5.6.4 Storage Required as of MySQL 5.6.4
YEAR 1 byte 1 byte
Data Type Storage Required Before MySQL 5.6.4 Storage Required as of MySQL 5.6.4
DATE 3 bytes 3 bytes
TIME 3 bytes 3 bytes + fractional seconds storage
DATETIME 8 bytes 5 bytes + fractional seconds storage
TIMESTAMP 4 bytes 4 bytes + fractional seconds storage
As of MySQL 5.6.4, storage for YEAR and DATE remains unchanged. However, TIME, DATETIME,
and TIMESTAMP are represented differently. DATETIME is packed more efficiently, requiring 5 rather
than 8 bytes for the nonfractional part, and all three parts have a fractional part that requires from 0
to 3 bytes, depending on the fractional seconds precision of stored values.
Fractional Seconds Precision Storage Required
0 0 bytes
1, 2 1 byte
3, 4 2 bytes
5, 6 3 bytes
For example, TIME(0), TIME(2), TIME(4), and TIME(6) use 3, 4, 5, and 6 bytes,
respectively. TIME and TIME(0) are equivalent and require the same storage.
For details about internal representation of temporal values, see MySQL Internals: Important
Algorithms and Structures.
String Type Storage Requirements
In the following table, M represents the declared column length in characters for nonbinary string
types and bytes for binary string types. L represents the actual length in bytes of a given string
value.
Data Type Storage Required
M w bytes, 0 <= M <= 255, where w is the number of bytes required for
the maximum-length character in the character set. See Section 14.8.1.2,
The Physical Row Structure of an InnoDB Tablefor information
CHAR(M) about CHAR data type storage requirements for InnoDB tables.
BINARY(M) M bytes, 0 <= M <= 255
L + 1 bytes if column values require 0 255 bytes, L + 2 bytes if values
VARCHAR(M), VARBINARY(M) may require more than 255 bytes
TINYBLOB, TINYTEXT L + 1 bytes, where L < 28
BLOB, TEXT L + 2 bytes, where L < 216
MEDIUMBLOB, MEDIUMTEXT L + 3 bytes, where L < 224
LONGBLOB, LONGTEXT L + 4 bytes, where L < 232
1 or 2 bytes, depending on the number of enumeration values (65,535
ENUM('value1','value2',...) values maximum)
1, 2, 3, 4, or 8 bytes, depending on the number of set members (64
SET('value1','value2',...) members maximum)
Variable-length string types are stored using a length prefix plus data. The length prefix requires
from one to four bytes depending on the data type, and the value of the prefix is L (the byte length of
the string). For example, storage for a MEDIUMTEXT value requires Lbytes to store the value plus
three bytes to store the length of the value.
To calculate the number of bytes used to store a particular CHAR, VARCHAR, or TEXT column value,
you must take into account the character set used for that column and whether the value contains
multibyte characters. In particular, when using a utf8 Unicode character set, you must keep in mind
that not all characters use the same number of bytes. utf8mb3 and utf8mb4 character sets can
require up to three and four bytes per character, respectively. For a breakdown of the storage used
for different categories of utf8mb3or utf8mb4 characters, see Section 10.1.9, Unicode Support.
VARCHAR, VARBINARY, and the BLOB and TEXT types are variable-length types. For each, the
storage requirements depend on these factors:
The actual length of the column value

The column's maximum possible length

The character set used for the column, because some character sets contain multibyte
characters

For example, a VARCHAR(255) column can hold a string with a maximum length of 255 characters.
Assuming that the column uses the latin1 character set (one byte per character), the actual
storage required is the length of the string (L), plus one byte to record the length of the string. For
the string 'abcd', L is 4 and the storage requirement is five bytes. If the same column is instead
declared to use the ucs2 double-byte character set, the storage requirement is 10 bytes: The length
of 'abcd' is eight bytes and the column requires two bytes to store lengths because the maximum
length is greater than 255 (up to 510 bytes).
The effective maximum number of bytes that can be stored in a VARCHAR or VARBINARY column is
subject to the maximum row size of 65,535 bytes, which is shared among all columns. For
a VARCHAR column that stores multibyte characters, the effective maximum number of characters is
less. For example, utf8mb3 characters can require up to three bytes per character, so
a VARCHAR column that uses the utf8mb3 character set can be declared to be a maximum of 21,844
characters. See Section C.10.4, Limits on Table Column Count and Row Size.
In general, the storage requirement for a JSON column is approximately the same as for
a LONGBLOB or LONGTEXT column; that is, the space consumed by a JSON document is roughly the
same as it would be for the document's string representation stored in a column of one of these
types. However, there is an overhead imposed by the binary encoding, including metadata and
dictionaries needed for lookup, of the individual values stored in the JSON document. For example,
a string stored in a JSON document requires 4 to 10 bytes additional storage, depending on the
length of the string and the size of the object or array in which it is stored.
In addition, MySQL imposes a limit on the size of any JSON document stored in a JSON column such
that it cannot be any larger than the value of max_allowed_packet.
InnoDB encodes fixed-length fields greater than or equal to 768 bytes in length as variable-length
fields, which can be stored off-page. For example, a CHAR(255) column can exceed 768 bytes if the
maximum byte length of the character set is greater than 3, as it is with utf8mb4.
The NDB storage engine supports variable-width columns. This means that a VARCHAR column in an
NDB Cluster table requires the same amount of storage as would any other storage engine, with the
exception that such values are 4-byte aligned. Thus, the string 'abcd' stored in
a VARCHAR(50) column using the latin1 character set requires 8 bytes (rather than 5 bytes for the
same column value in a MyISAM table).
TEXT and BLOB columns are implemented differently in the NDB storage engine, wherein each row in
a TEXT column is made up of two separate parts. One of these is of fixed size (256 bytes), and is
actually stored in the original table. The other consists of any data in excess of 256 bytes, which is
stored in a hidden table. The rows in this second table are always 2,000 bytes long. This means that
the size of a TEXT column is 256 if size <= 256 (where size represents the size of the row);
otherwise, the size is 256 + size + (2000 (size 256) % 2000).
The size of an ENUM object is determined by the number of different enumeration values. One byte is
used for enumerations with up to 255 possible values. Two bytes are used for enumerations having
between 256 and 65,535 possible values. See Section 11.4.4, The ENUM Type.
The size of a SET object is determined by the number of different set members. If the set size is N,
the object occupies (N+7)/8 bytes, rounded up to 1, 2, 3, 4, or 8 bytes. A SET can have a maximum
of 64 members. See Section 11.4.5, The SET Type.
Spatial Type Storage Requirements
MySQL stores geometry values using 4 bytes to indicate the SRID followed by the WKB
representation of the value. The LENGTH()function returns the space in bytes required for value
storage.
For descriptions of WKB and internal storage formats for spatial values, see Section 11.5.3.1,
Supported Spatial Data Formats.

PREV HOME UP NEXT


User Comments
Posted by Marc Bouffard on August 4, 2004
Had a lot of trouble finding the maximum table size in bytes for capacity planning. More specifically it was
InnoDB tables that I had a problem with. Average row size is good, but I wanted maximum row size.

I checked several products and could not find what I wanted. Some of the tables I deal with are 300+ fields and
so manual calculation was not practical.

So I wrote a little perl script that does it. Thought it might be of some use, so I include it here...it does all field
types except enum/set types. It does not calculate anything regarding index size.

Just do a mysqldump -d (just the schema) of your DB to a file, and run this perl script specifying the schema file
as the only argument.
----------------------------------------------------------------
#!/usr/bin/perl
use Data::Dumper;
use strict;
$| = 1;

my %DataType =
("TINYINT"=>1,
"SMALLINT"=>2,
"MEDIUMINT"=>3,
"INT"=>4,
"BIGINT"=>8,
"FLOAT"=>'if ($M <= 24) {return 4;} else {return 8;}',
"DOUBLE"=>8,
"DECIMAL"=>'if ($M < $D) {return $D + 2;} elsif ($D > 0) {return $M + 2;} else {return $M + 1;}',
"NUMERIC"=>'if ($M < $D) {return $D + 2;} elsif ($D > 0) {return $M + 2;} else {return $M + 1;}',
"DATE"=>3,
"DATETIME"=>8,
"TIMESTAMP"=>4,
"TIME"=>3,
"YEAR"=>1,
"CHAR"=>'$M',
"VARCHAR"=>'$M+1',
"TINYBLOB"=>'$M+1',
"TINYTEXT"=>'$M+1',
"BLOB"=>'$M+2',
"TEXT"=>'$M+2',
"MEDIUMBLOB"=>'$M+3',
"MEDIUMTEXT"=>'$M+3',
"LONGBLOB"=>'$M+4',
"LONGTEXT"=>'$M+4');

my $D;
my $M;
my $dt;
my $fieldCount = 0;
my $byteCount = 0;
my $fieldName;
open (TABLEFILE,"< $ARGV[0]");
LOGPARSE:while (<TABLEFILE>)
{
chomp;
if ( $_ =~ s/create table[ ]*([a-zA-Z_]*).*/$1/i )
{
print "Fieldcount: $fieldCount Bytecount: $byteCount\n" if $fieldCount;
$fieldCount = 0;
$byteCount = 0;
print "\nTable: $_\n";
next;
}
next if $_ !~ s/(.*)[ ]+(TINYINT[ ]*\(*[0-9,]*\)*|SMALLINT[ ]*\(*[0-9,]*\)*|MEDIUMINT[ ]*\(*[0-9,]*\)*|INT[ ]*\(*[0-
9,]*\)*|BIGINT[ ]*\(*[0-9,]*\)*|FLOAT[ ]*\(*[0-9,]*\)*|DOUBLE[ ]*\(*[0-9,]*\)*|DECIMAL[ ]*\(*[0-9,]*\)*|NUMERIC[
]*\(*[0-9,]*\)*|DATE[ ]*\(*[0-9,]*\)*|DATETIME[ ]*\(*[0-9,]*\)*|TIMESTAMP[ ]*\(*[0-9,]*\)*|TIME[ ]*\(*[0-9,]*\)*|YEAR[
]*\(*[0-9,]*\)*|CHAR[ ]*\(*[0-9,]*\)*|VARCHAR[ ]*\(*[0-9,]*\)*|TINYBLOB[ ]*\(*[0-9,]*\)*|TINYTEXT[ ]*\(*[0-
9,]*\)*|BLOB[ ]*\(*[0-9,]*\)*|TEXT[ ]*\(*[0-9,]*\)*|MEDIUMBLOB[ ]*\(*[0-9,]*\)*|MEDIUMTEXT[ ]*\(*[0-
9,]*\)*|LONGBLOB[ ]*\(*[0-9,]*\)*|LONGTEXT[ ]*\(*[0-9,]*\)*).*/$2/gix;
$fieldName=$1;
$_=uc;
$D=0;
($D = $_) =~ s/.*\,([0-9]+).*/$1/g if ( $_ =~ m/\,/ );
$_ =~ s/\,([0-9]*)//g if ( $_ =~ m/\,/ );
($M = $_) =~ s/[^0-9]//g;
$M=0 if ! $M;
($dt = $_) =~ s/[^A-Za-z_]*//g;
print "$fieldName $_:\t".eval($DataType{"$dt"})." bytes\n";
++$fieldCount;
$byteCount += eval($DataType{"$dt"});
}
print "Fieldcount: $fieldCount Bytecount: $byteCount\n";

Posted by Rich Tomasso on April 5, 2005


Here's a modification of Marc's script above that also handles ENUM's. Enjoy.

#!/usr/bin/perl
use Data::Dumper;
use strict;
$| = 1;

my %DataType =
("TINYINT"=>1, "SMALLINT"=>2, "MEDIUMINT"=>3,
"INT"=>4, "BIGINT"=>8,
"FLOAT"=>'if ($M <= 24) {return 4;} else {return 8;}',
"DOUBLE"=>8,
"DECIMAL"=>'if ($M < $D) {return $D + 2;} elsif ($D > 0) {return $M + 2;} else {return $M + 1;}',
"NUMERIC"=>'if ($M < $D) {return $D + 2;} elsif ($D > 0) {return $M + 2;} else {return $M + 1;}',
"DATE"=>3, "DATETIME"=>8, "TIMESTAMP"=>4, "TIME"=>3, "YEAR"=>1,
"CHAR"=>'$M', "VARCHAR"=>'$M+1',
"ENUM"=>1,
"TINYBLOB"=>'$M+1', "TINYTEXT"=>'$M+1',
"BLOB"=>'$M+2', "TEXT"=>'$M+2',
"MEDIUMBLOB"=>'$M+3', "MEDIUMTEXT"=>'$M+3',
"LONGBLOB"=>'$M+4', "LONGTEXT"=>'$M+4');
my ($D, $M, $dt);

my $fieldCount = 0;
my $byteCount = 0;
my $fieldName;

open (TABLEFILE,"< $ARGV[0]");

LOGPARSE:while (<TABLEFILE>) {
chomp;
if ( $_ =~ s/create table[ ]`*([a-zA-Z_]*).*`/$1/i ) {
print "Fieldcount: $fieldCount Bytecount: $byteCount\n" if $fieldCount;
$fieldCount = 0;
$byteCount = 0;
print "\nTable: $_\n";
next;
}
next if $_ !~ s/(.*)[ ]+(TINYINT[ ]*\(*[0-9,]*\)*|SMALLINT[ ]*\(*[0-9,]*\)*|MEDIUMINT[ ]*\(*[0-9,]*\)*|INT[ ]*\(*[0-
9,]*\)*|BIGINT[ ]*\(*[0-9,]*\)*|FLOAT[ ]*\(*[0-9,]*\)*|DOUBLE[ ]*\(*[0-9,]*\)*|DECIMAL[ ]*\(*[0-9,]*\)*|NUMERIC[
]*\(*[0-9,]*\)*|DATE[ ]*\(*[0-9,]*\)*|DATETIME[ ]*\(*[0-9,]*\)*|TIMESTAMP[ ]*\(*[0-9,]*\)*|TIME[ ]*\(*[0-9,]*\)*|YEAR[
]*\(*[0-9,]*\)*|CHAR[ ]*\(*[0-9,]*\)*|VARCHAR[ ]*\(*[0-9,]*\)*|TINYBLOB[ ]*\(*[0-9,]*\)*|TINYTEXT[ ]*\(*[0-
9,]*\)*|ENUM[ ]*\(*['A-Za-z_,]*\)*|BLOB[ ]*\(*[0-9,]*\)*|TEXT[ ]*\(*[0-9,]*\)*|MEDIUMBLOB[ ]*\(*[0-
9,]*\)*|MEDIUMTEXT[ ]*\(*[0-9,]*\)*|LONGBLOB[ ]*\(*[0-9,]*\)*|LONGTEXT[ ]*\(*[0-9,]*\)*).*/$2/gix;
$fieldName=$1;
$_=uc;
$D=0;
($D = $_) =~ s/.*\,([0-9]+).*/$1/g if ( $_ =~ m/\,/ );
$_ =~ s/\,([0-9]*)//g if ( $_ =~ m/\,/ );
($M = $_) =~ s/[^0-9]//g;
$M=0 if ! $M;
($dt = $_) =~ s/\(.*\)//g;
$dt =~ s/[^A-Za-z_]*//g;
print "$fieldName $_:\t".eval($DataType{"$dt"})." bytes\n";
++$fieldCount;
$byteCount += eval($DataType{"$dt"});
}
print "Fieldcount: $fieldCount Bytecount: $byteCount\n";

Posted by Alex Gheorghiu on January 30, 2009


The above scripts are not taking into account several important information (so they are outdated)

1. the database/table encoding.


If you have an UTF8 encoding for a varchar(100) that it will take up 300 bytes (3 bytes per UTF symbol)
"[...]As of MySQL 4.1, to calculate the number of bytes used to store a particular CHAR, VARCHAR, or TEXT
column value, you must take into account the character set used for that column and whether the value
contains multi-byte characters. In particular, when using the utf8 Unicode character set, you must keep in mind
that not all utf8 characters use the same number of bytes and can require up to three bytes per character."

2. enum can have either 1 or 2 bytes


"[...]The size of an ENUM object is determined by the number of different enumeration values. One byte is used
for enumerations with up to 255 possible values. Two bytes are used for enumerations having between 256
and 65,535 possible values."

Posted by Rafa Michalski on February 19, 2009


Here I wrote another script based on Marc's, that takes into account what Alex wrote and more.
It calculates VARCHAR/CHAR/TEXT taking CHARSET or COLLATION into account, calculates properly SET
and ENUM size, DECIMAL/NUMERIC is calculated according to >5.0.3 packed standard.
Calculates also least row byte size for dynamic row length tables.
It uses "mysql" and "mysqldump" tools internally.
Any argument to this script is provided as an argument for mysqldump.
Example: {scriptname} --all-databases
Please report any bug, especially when it comes to size calculations. Enjoy.

----------- copy here --------------


#!/usr/bin/perl
use strict;
$| = 1;

my %DataType = (
"TINYINT"=>1, "SMALLINT"=>2, "MEDIUMINT"=>3, "INT"=>4, "INTEGER"=>4, "BIGINT"=>8,
"FLOAT"=>'$M<=24?4:8', "DOUBLE"=>8,
"DECIMAL"=>'int(($M-$D)/9)*4+int(((($M-$D)%9)+1)/2)+int($D/9)*4+int((($D%9)+1)/2)',
"NUMERIC"=>'int(($M-$D)/9)*4+int(((($M-$D)%9)+1)/2)+int($D/9)*4+int((($D%9)+1)/2)',
"BIT"=>'($M+7)>>3',
"DATE"=>3, "TIME"=>3, "DATETIME"=>8, "TIMESTAMP"=>4, "YEAR"=>1,
"BINARY"=>'$M',"CHAR"=>'$M*$CL',
"VARBINARY"=>'$M+($M>255?2:1)', "VARCHAR"=>'$M*$CL+($M>255?2:1)',
"ENUM"=>'$M>255?2:1', "SET"=>'($M+7)>>3',
"TINYBLOB"=>9, "TINYTEXT"=>9,
"BLOB"=>10, "TEXT"=>10,
"MEDIUMBLOB"=>11, "MEDIUMTEXT"=>11,
"LONGBLOB"=>12, "LONGTEXT"=>12
);

my %DataTypeMin = (
"VARBINARY"=>'($M>255?2:1)', "VARCHAR"=>'($M>255?2:1)'
);

my ($D, $M, $S, $C, $L, $dt, $dp ,$bc, $CL);


my $fieldCount = 0;
my $byteCount = 0;
my $byteCountMin = 0;
my @fields = ();
my $fieldName;
my $tableName;
my $defaultDbCL = 1;
my $defaultTableCL = 1;
my %charsetMaxLen;
my %collationMaxLen;

open (CHARSETS, "mysql -B --skip-column-names information_schema -e 'select


CHARACTER_SET_NAME,MAXLEN from CHARACTER_SETS;' |");
%charsetMaxLen = map ( ( /^(\w+)/ => /(\d+)$/ ), <CHARSETS>);
close CHARSETS;

open (COLLATIONS, "mysql -B --skip-column-names information_schema -e 'select


COLLATION_NAME,MAXLEN from CHARACTER_SETS INNER JOIN COLLATIONS
USING(CHARACTER_SET_NAME);' |");
%collationMaxLen = map ( ( /^(\w+)/ => /(\d+)$/ ), <COLLATIONS>);
close COLLATIONS;

open (TABLEINFO, "mysqldump -d --compact ".join(" ",@ARGV)." |");

while (<TABLEINFO>) {
chomp;
if ( ($S,$C) = /create database.*?`([^`]+)`.*default\scharacter\sset\s+(\w+)/i ) {
$defaultDbCL = exists $charsetMaxLen{$C} ? $charsetMaxLen{$C} : 1;
print "Database: $S".($C?" DEFAULT":"").($C?" CHARSET $C":"")." (bytes per char: $defaultDbCL)\n\n";
next;
}
if ( /^create table\s+`([^`]+)`.*/i ) {
$tableName = $1;
@fields = ();
next;
}
if ( $tableName && (($C,$L) = /^\)(?:.*?default\scharset=(\w+))?(?:.*?collate=(\w+))?/i) ) {
$defaultTableCL = exists $charsetMaxLen{$C} ? $charsetMaxLen{$C} : (exists $collationMaxLen{$L} ?
$collationMaxLen{$L} : $defaultDbCL);
print "Table: $tableName".($C||$L?" DEFAULT":"").($C?" CHARSET $C":"").($L?" COLLATION $L":"")." (bytes
per char: $defaultTableCL)\n";
$tableName = "";
$fieldCount = 0;
$byteCount = 0;
$byteCountMin = 0;
while ($_ = shift @fields) {
if ( ($fieldName,$dt,$dp,$M,$D,$S,$C,$L) = /\s\s`([^`]+)`\s+([a-
z]+)(\((\d+)(?:,(\d+))?\)|\((.*)\))?(?:.*?character\sset\s+(\w+))?(?:.*?collate\s+(\w+))?/i ) {
$dt = uc $dt;
if (exists $DataType{$dt}) {
if (length $S) {
$M = ($S =~ s/(\'.*?\'(?!\')(?=,|$))/$1/g);
$dp = "($M : $S)"
}
$D = 0 if !$D;
$CL = exists $charsetMaxLen{$C} ? $charsetMaxLen{$C} : (exists $collationMaxLen{$L} ?
$collationMaxLen{$L} : $defaultTableCL);
$bc = eval($DataType{$dt});
$byteCount += $bc;
$byteCountMin += exists $DataTypeMin{$dt} ? $DataTypeMin{$dt} : $bc;
} else {
$bc = "??";
}
$fieldName.="\t" if length($fieldName) < 8;
print "bytes:\t".$bc."\t$fieldName\t$dt$dp".($C?" $C":"").($L?" COLL $L":"")."\n";
++$fieldCount;
}
}
print "total:\t$byteCount".($byteCountMin!=$byteCount?"\tleast: $byteCountMin":"\t\t")."\tcolumns:
$fieldCount\n\n";
next;
}
push @fields, $_;
}
close TABLEINFO;

Posted by Jake Drew on May 26, 2011


It appears that TEXT fields with no length specified default to a length of 10 Bytes in your script output.
However, information_schema.columns.character_maximum_length lists all my text fields as 65535?

ex:
bytes: 10 abstract TEXT COLL utf8_unicode_ci

Is this a space calculation bug in the script?


Posted by Jake Drew on June 9, 2011
Here is an SQL script that can be used to determine maximum space per row for InnoDB tables using the
COMPACT row format.

I have tested the results against my database structures loaded with maximum length records @ 100,000 ,
500,000 , and 1,000,000 records. The results seem to be fairly accurate.

I based the maximum space calculations for fields using the following MySQL reference above. I based the
calculations for InnoDB Compact row format primary and secondary index record headers using the following
MySQL reference:

http://dev.mysql.com/doc/refman/5.1/en/innodb-physical-record.html

Notes:

The SQL produces all sizes in Bytes. If the SQL encounters an unknown data type, it assigns a byte value of
999999999999999 Bytes for that field. You must update TABLE_SCHEMA = 'Your Schema Name' in two
places. The query add no overhead factor to it's results. Any overhead factor must be added to the results
produced by this query.

SQL Below:

SELECT B.TABLE_SCHEMA
, B.TABLE_NAME
, (CASE WHEN SUM(PK_BYTES) = 0 THEN 6 ELSE SUM(PK_BYTES) END) + 18 AS PK_BYTES_TOT -- 18
= Index Record Header (5) + Transaction ID (6) + Roll Pointer (7)
, SUM(FIELD_BYTE_SPACE) AS FIELD_BYTES_TOT
, SUM(IX_BYTES) AS IX_FIELD_BYTES_TOT
, SUM(CASE WHEN IX_BYTES > 0 THEN 1 ELSE 0 END) AS IX_FIELD_COUNT
, ((CASE WHEN SUM(PK_BYTES) = 0 THEN 6 ELSE SUM(PK_BYTES) END) + 18) +
SUM(FIELD_BYTE_SPACE) + SUM(IX_BYTES) AS TABLE_BYTES_TOT
FROM
(
SELECT A.*
, CASE WHEN COLUMN_KEY = 'PRI'THEN FIELD_BYTE_SPACE ELSE 0 END AS PK_BYTES
, CASE WHEN A.COLUMN_KEY <> 'PRI'
AND A.COLUMN_KEY <> '' THEN (PK_BYTE_SPACE + FIELD_BYTE_SPACE) ELSE 0 END AS IX_BYTES
FROM (
SELECT PK_SP.TABLE_SCHEMA
, PK_SP.TABLE_NAME
, PK_SP.COLUMN_NAME
, DATA_TYPE
, CHARACTER_MAXIMUM_LENGTH
, NUMERIC_PRECISION
, IS_NULLABLE
, COLUMN_KEY
, CHARACTER_SET_NAME
, CHARACTER_OCTET_LENGTH
, (CASE -- CHARACTER FIELDS
WHEN DATA_TYPE = 'varchar' THEN CHARACTER_MAXIMUM_LENGTH + 1
WHEN DATA_TYPE = 'char' THEN CHARACTER_MAXIMUM_LENGTH
WHEN DATA_TYPE = 'tinyblob'
OR DATA_TYPE = 'tinytext' THEN CHARACTER_MAXIMUM_LENGTH + 1
WHEN DATA_TYPE = 'blob'
OR DATA_TYPE = 'text' THEN CHARACTER_MAXIMUM_LENGTH + 2
WHEN DATA_TYPE = 'mediumblob'
OR DATA_TYPE = 'mediumtext' THEN CHARACTER_MAXIMUM_LENGTH + 3
WHEN DATA_TYPE = 'largeblob'
OR DATA_TYPE = 'largetext' THEN CHARACTER_MAXIMUM_LENGTH + 4
-- NUMERIC FIELDS
WHEN DATA_TYPE = 'tinyint' THEN 1
WHEN DATA_TYPE = 'smallint' THEN 2
WHEN DATA_TYPE = 'mediumint' THEN 3
WHEN DATA_TYPE = 'int'
OR DATA_TYPE = 'integer' THEN 4
WHEN DATA_TYPE = 'bigint' THEN 8
WHEN DATA_TYPE = 'float'
AND (NUMERIC_PRECISION <= 24
OR NUMERIC_PRECISION IS NULL) THEN 4
WHEN DATA_TYPE = 'float'
AND NUMERIC_PRECISION > 24 THEN 8
WHEN DATA_TYPE = 'bit' THEN (NUMERIC_PRECISION + 7) / 8
WHEN DATA_TYPE = 'double'
OR DATA_TYPE = 'numeric' THEN
(FLOOR(NUMERIC_PRECISION/9)*4) + ROUND((NUMERIC_PRECISION-
FLOOR(NUMERIC_PRECISION/9)*9)*.5,0)
-- DATETIME FIELDS
WHEN DATA_TYPE = 'date'
OR DATA_TYPE = 'time' THEN 3
WHEN DATA_TYPE = 'datetime' THEN 8
WHEN DATA_TYPE = 'timestamp' THEN 4
WHEN DATA_TYPE = 'year' THEN 1
-- BINARY FIELDS
WHEN DATA_TYPE = 'binary' THEN CHARACTER_MAXIMUM_LENGTH
ELSE 999999999999999 END) +
(CASE WHEN IS_NULLABLE = 'YES' THEN 1 ELSE 0 END) AS FIELD_BYTE_SPACE
, CASE WHEN PK_BYTE_SPACE IS NULL THEN 6 + 18 ELSE PK_BYTE_SPACE + 18 END AS
PK_BYTE_SPACE
FROM information_schema.columns AS PK_SP
LEFT OUTER JOIN
(SELECT TABLE_SCHEMA
, TABLE_NAME
, SUM((CASE -- CHARACTER FIELDS
WHEN DATA_TYPE = 'varchar' THEN CHARACTER_MAXIMUM_LENGTH + 1
WHEN DATA_TYPE = 'char' THEN CHARACTER_MAXIMUM_LENGTH
WHEN DATA_TYPE = 'tinyblob'
OR DATA_TYPE = 'tinytext' THEN CHARACTER_MAXIMUM_LENGTH + 1
WHEN DATA_TYPE = 'blob'
OR DATA_TYPE = 'text' THEN CHARACTER_MAXIMUM_LENGTH + 2
WHEN DATA_TYPE = 'mediumblob'
OR DATA_TYPE = 'mediumtext' THEN CHARACTER_MAXIMUM_LENGTH + 3
WHEN DATA_TYPE = 'largeblob'
OR DATA_TYPE = 'largetext' THEN CHARACTER_MAXIMUM_LENGTH + 4
-- NUMERIC FIELDS
WHEN DATA_TYPE = 'tinyint' THEN 1
WHEN DATA_TYPE = 'smallint' THEN 2
WHEN DATA_TYPE = 'mediumint' THEN 3
WHEN DATA_TYPE = 'int'
OR DATA_TYPE = 'integer' THEN 4
WHEN DATA_TYPE = 'bigint' THEN 8
WHEN DATA_TYPE = 'float'
AND (NUMERIC_PRECISION <= 24
OR NUMERIC_PRECISION IS NULL) THEN 4
WHEN DATA_TYPE = 'float'
AND NUMERIC_PRECISION > 24 THEN 8
WHEN DATA_TYPE = 'bit' THEN (NUMERIC_PRECISION + 7) / 8
WHEN DATA_TYPE = 'double'
OR DATA_TYPE = 'numeric' THEN
(FLOOR(NUMERIC_PRECISION/9)*4) + ROUND((NUMERIC_PRECISION-
FLOOR(NUMERIC_PRECISION/9)*9)*.5,0)
-- DATETIME FIELDS
WHEN DATA_TYPE = 'date'
OR DATA_TYPE = 'time' THEN 3
WHEN DATA_TYPE = 'datetime' THEN 8
WHEN DATA_TYPE = 'timestamp' THEN 4
WHEN DATA_TYPE = 'year' THEN 1
-- BINARY FIELDS
WHEN DATA_TYPE = 'binary' THEN CHARACTER_MAXIMUM_LENGTH
ELSE 999999999999999 END) +
(CASE WHEN IS_NULLABLE = 'YES' THEN 1 ELSE 0 END)) AS PK_BYTE_SPACE
FROM information_schema.columns COL_SP
WHERE COLUMN_KEY = 'PRI'
AND TABLE_SCHEMA = 'studypods_dev'
GROUP BY TABLE_SCHEMA
, TABLE_NAME) AS IX_SP
ON PK_SP.TABLE_SCHEMA = IX_SP.TABLE_SCHEMA
AND PK_SP.TABLE_NAME = IX_SP.TABLE_NAME
WHERE PK_SP.TABLE_SCHEMA = 'studypods_dev') AS A
) AS B
GROUP BY B.TABLE_SCHEMA
, B.TABLE_NAME

Posted by Rick James on September 15, 2012


The formulas above apply to MyISAM. For InnoDB data, the quick answer is to calculate for MyISAM, then
double or triple that value.

The more complex way is something like:


Step 1: Compute basic length of each field (without length field for VAR fields); add 1 or 2 to that length. (1 if all
the fields are 'short')
Step 2: Add those together, plus 29 bytes for record overhead.
Step 3: Add 40% for the blocks not being full.
Step 4: Multiply by the number of rows.

That contorted computation can easily be off by a significant amount, either way.

Posted by Sean Nolan on October 17, 2012


This page lists the BLOB and TEXT types and gives a formula for calculating the storage required, but it does
not give the different maximum sizes. Here they are:

TINYTEXT - 255 bytes


TEXT - 65535 bytes
MEDIUMTEXT - 16,777,215 bytes (2^24 - 1)
LONGTEXT - 4G bytes (2^32 1)

TINYBLOB - 255 bytes


BLOB - 65535 bytes
MEDIUMBLOB - 16,777,215 bytes (2^24 - 1)
LONGBLOB - 4G bytes (2^32 1)

Field types in Microsoft Access


Fields in a Microsoft Access database can be of many different data types. Access supports
different kinds of text, numbers, dates and some more special data types. This document will
describe each data type and note which versions of Microsoft Access support it.
Textual types
Text
The Text data type is used for short text fields of limited length, and can contain up to
255 characters.
Memo
A Memo field is a virtually unlimited text field. It can store up to 1GB of text.
Microsoft Access supports text in a variety of languages and alphabets. Access 97 supported
multiple code pages in the same document. This worked great in most cases, but caused
problems when columns contained text in different alphabets. Therefore Microsoft switched to
the Unicode character encoding in Access 2000. MDB Viewer automatically supports all
encodings used in Access.

Numeric Types
Byte, Integer and Long Integer
Integers in Access come in 1, 2 and 4 byte varieties. The single byte number is
named Byte (Range 0-255), the two-byte number is named Integer (-32768 to 32767)
and then there is the Long Integer (-2 billion to 2 billion).
Decimal
Decimal numbers are so called fixed point numbers. They can have a fractional part, and
they can be either positive or negative. Decimals have a fixed number of digits to left and
to the right of the decimal point. The maximum total number of digits supported by
Access is 28. Decimals are used for exact numeric values. Despite the name "Decimal"
you can also use the decimal data type for integers larger than the range supported by
the Long Integer type. Decimals are only supported by Microsoft Access 2000 and later.
A decimal number uses 17 bytes of disk space.
Currency
The currency type is a special kind of decimal, with up to 4 digits on the right of the
decimal point and up to 15 on the left. It was introduced for financial data and is
available in all versions of Access. This type uses 8 bytes of disk space.
Float and Double
Floating point numbers are similar to numbers written in scientific notation, and come in
two varieties: float and double. They have a precision of up about 7 decimal digits
(float) or 15 digits (double). The exponent (location of decimal point) is stored separately,
an can range from -45 to +38 (float) or from -324 to 308 (double). Use floating point
numbers if you require a large range but only limited precision. Floats use 4 bytes, and
doubles use 8 bytes of disk space.

Other Types
Date/Time
Specifies a specific point in time (Date and time of day). Dates are internally stored as
an 8 byte double precision floating point numbers, so the range is virtually unlimited.
(Dates up to 2 million AD can be stored with a precision of 1 second.) MDB Viewer
exports dates in the format YYYY-MM-DD HH:MM:SS.
Yes/No
A boolean value that can be either on or off, displayed as a check box in Microsoft
Access. Displayed as 0 or 1 in MDB Viewer.
OLE Object
An OLE object field can contain documents, such as images, text files, Microsoft Word
files or Microsoft Excel files. The size of this field is limited to 1 GB. MDB Viewer for Mac
supports many kinds of OLE objects, such as Images, Word documents and PDF files.
Sometimes Access stores OLE Object in an unknown data structure that I do not
understand yet. These files show up as unknown files.
You can extract OLE files by dragging the icon to the Finder.

Complex Types
Microsoft Access 2007 introduced a number of types they call Complex Columns. These types
are multivalued fields, attachments, and version history for memo fields. Common to all these
fields is that they can contain multiple values per row, seemingly against the rules of database
normalisation. However, Access internally stores these values in normalized tables that are
hidden from the user. MDB Viewer makes these hidden tables accessible for easy exporting.
Multi-Valued Field
A multi-valued field can contain multiple numbers of any of the types listed above. The
actual value stored in the complex field is a key that links to the numbers stored in the
helper table.
Attachments
Attachment fields are conceptually similar to multi-valued fields, except that the helper
table contains files rather than numbers.
Memo version history
For these fields, the helper table contains the previous contents of a field together with a
time stamp.
For an example of working with multi-valued fields, see the section on viewing Access
databases.

Data Types
As you may have noticed, VB supports several data types. These are what the main
'Types' that you can declare your variables as. For example:
Dim intCount As Integer

is an Integer. You always should tell Visual Basic what sort of data the variable will
hold. This will make your code easier to use, and will also save memory. Different
types of variables need different amounts of memory. You need to use the smallest
amount of memory. For example, if you will need to store a number from 0 - 255 in a
variable, you can save memory by declaring it as a Byte (1 byte) rather than as an
Integer (2 bytes). This is not really very much memory, but if you are untidy with all
your variables, your application will use much more memory than it has to.

The table below lists the various Data Types, what data they can store and how many
bytes they use.

Data type Storage size Range


Byte 1 byte 0 to 255
Boolean 2 bytes True or False
Integer 2 bytes -32,768 to 32,767
Long (long
4 bytes -2,147,483,648 to 2,147,483,647
integer)
Single (single-
-3.402823E38 to -1.401298E-45 for negative values; 1.401298E-
precision 4 bytes
45 to 3.402823E38 for positive values
floating-point)
Double
-1.79769313486232E308 to -4.94065645841247E-324 for
(double-
8 bytes negative values; 4.94065645841247E-324 to
precision
1.79769313486232E308 for positive values
floating-point)
Currency
(scaled 8 bytes -922,337,203,685,477.5808 to 922,337,203,685,477.5807
integer)
+/-79,228,162,514,264,337,593,543,950,335 with no decimal
point; +/-7.9228162514264337593543950335 with 28 places to
Decimal 14 bytes
the right of the decimal; smallest non-zero number is +/-
0.0000000000000000000000000001
Date 8 bytes January 1, 100 to December 31, 9999
Object 4 bytes Any Object reference
String
10 bytes +
(variable- 0 to approximately 2 billion
string length
length)
String (fixed- Length of
1 to approximately 65,400
length) string
Variant (with
16 bytes Any numeric value up to the range of a Double
numbers)
Variant (with 22 bytes +
Same range as for variable-length String
characters) string length

Visual Basic 6 (VB6) Data Types, Modules And Operators


Visual Basic uses building blocks such as Variables, Data Types, Procedures, Functions and Control
Structures in its programming environment. This section concentrates on the programming fundamentals
of Visual Basic with the blocks specified.

Modules
Code in Visual Basic is stored in the form of modules. The three kind of modules are Form Modules,
Standard Modules and Class Modules. A simple application may contain a single Form, and the code
resides in that Form module itself. As the application grows, additional Forms are added and there may
be a common code to be executed in several Forms. To avoid the duplication of code, a separate module
containing a procedure is created that implements the common code. This is a standard Module.

Class module (.CLS filename extension) are the foundation of the object oriented programming in Visual
Basic. New objects can be created by writing code in class modules. Each module can contain:

Declarations : May include constant, type, variable and DLL procedure declarations.

Procedures : A sub function, or property procedure that contain pieces of code that can be executed as
a unit.

These are the rules to follow when naming elements in VB - variables, constants, controls, procedures,
and so on:

A name must begin with a letter.


May be as much as 255 characters long (but don't forget that somebody has to type the stuff!).
Must not contain a space or an embedded period or type-declaration characters used to specify a
data type; these are ! # % $ & @
Must not be a reserved word (that is part of the code, like Option, for example)
The dash, although legal, should be avoided because it may be confused with the minus sign.
Instead of First-name use First_name or FirstName.

Data types in Visual Basic 6


By default Visual Basic variables are of variant data types. The variant data type can store numeric,
date/time or string data. When a variable is declared, a data type is supplied for it that determines the
kind of data they can store. The fundamental data types in Visual Basic including variant are integer, long,
single, double, string, currency, byte and boolean. Visual Basic supports a vast array of data types. Each
data type has limits to the kind of information and the minimum and maximum values it can hold. In
addition, some types can interchange with some other types. A list of Visual Basic's simple data types are
given below.

1. Numeric

Byte Store integer values in the range of 0 - 255


Integer Store integer values in the range of (-32,768) - (+ 32,767)
Long Store integer values in the range of (- 2,147,483,468) - (+ 2,147,483,468)
Single Store floating point value in the range of (-3.4x10-38) - (+ 3.4x1038)
Double Store large floating value which exceeding the single data type value
store monetary values. It supports 4 digits to the right of decimal point and 15
Currency
digits to the left

2. String

Use to store alphanumeric values. A variable length string can store approximately 4 billion characters

3. Date

Use to store date and time values. A variable declared as date type can store both date and time values
and it can store date values 01/01/0100 up to 12/31/9999
4. Boolean

Boolean data types hold either a true or false value. These are not stored as numeric values and cannot
be used as such. Values are internally stored as -1 (True) and 0 (False) and any non-zero value is
considered as true.

5. Variant

Stores any type of data and is the default Visual Basic data type. In Visual Basic if we declare a variable
without any data type by default the data type is assigned as default.

Operators in Visual Basic


Arithmetical Operators

Operators Description Example Result

+ Add 5+5 10

- Substract 10-5 5

/ Divide 25/5 5

\ Integer Division 20\3 6

* Multiply 5*4 20

^ Exponent (power of) 3^3 27

Mod Remainder of division 20 Mod 6 2

& String concatenation "George"&" "&"Bush" "George Bush"

Relational Operators

Operators Description Example Result

> Greater than 10>8 True

< Less than 10<8 False

>= Greater than or equal to 20>=10 True

<= Less than or equal to 10<=20 True

<> Not Equal to 5<>4 True

= Equal to 5=7 False

Logical Operators
Operators Description

OR Operation will be true if either of the operands is true

AND Operation will be true only if both the operands are true

Visual Basic/Data Types


< Visual Basic

Data types in Visual Basic can be divided into three groups:

Native: Types that are understood directly by the Visual Basic compiler without assistance from
the programmer
User-defined: commonly referred to by the initials UDT, meaning User defined Type, these
correspond to Pascal records or C structs
Classes: the basis for object oriented programming in Visual Basic. Classes include forms, add-
ins, and database designers.

Contents
[hide]

1Built in Types
2Byte, Integer & Long
3Single & Double
4String
5Structure
6Enumeration
7Type Test

Built in Types[edit]
The built in types are:
Byte
8 bit, unsigned
Integer
16 bit, signed
Long
32 bit signed
Single

32 bit floating point, range about


Double

64 bit IEEE floating point, range about


Currency
exact representation of decimal numbers of up to four decimal places
String
dynamically allocated Unicode strings, theoretical capacity about characters.
Collection
an associative array of Variants.
Date
8 byte date/time value range January 1, 100 to December 31, 9999
Object
a holder for any type of Object.
Variant
a holder for any type of value or object.

Byte, Integer & Long[edit]


Example:

Dim a as Byte
Dim i as Integer
Dim x,y as Long 'Define two variables.
Note that only the last variable will be a
long integer.

Now those variables will only be capable of storing


integer values (without decimal). Long integers can
store a number with a bigger range of value than
integers but they occupy a bigger space of RAM.

Type Storage Range of Values

Byte 1 byte 0 to 255

Integer 2 bytes -32,768 to 32,767

Long 4 bytes -2,147,483,648 to 2,147,483,647

Some functions you need to know: Int()


Int() converts a decimal value into an integer value:

Dim i as Integer
i=Int(3.9)
Print i 'Prints 3
Single & Double[edit]
These data types can store decimal values. "Double"
compared to "Single" is similar to the "Long" compared
to "Integer":

Type Storage Range of Values

-3.402823E+38 to -1.401298E-45 for


negative values
Single 4 bytes
1.401298E-45 to 3.402823E+38 for
positive values.

-1.79769313486232E+308 to -
4.94065645841247E-324 for negative
values
Double 8 bytes
4.94065645841247E-324 to
1.79769313486232E+308 for positive
values.

Some useful functions: Round()


Round() rounds off a decimal to a certain number of
decimal digits that the programmer wants. The first
argument should be a decimal value which you want to
round off. The second argument specifies the number
of decimal digits you want, for example:

Dim pi as Double
pi=3.141592653589
pi=Round(pi,2) 'Rounds off
3.141592653589 to only two decimal digits
Print pi 'Prints 3.14

String[edit]
A string is an array of characters. As an example:

Dim a As String
a = "This is a string"

Strings can be concatenated (connected together to


form a new string) using the "&" operator. For example,
dim b as String
b = "Wiki" & "book" & "s"
Print b 'Prints "Wikibooks"

A normal string variable occupies 10 bytes of RAM,


plus the string's size, and can hold up to 2 billion
characters!
Some frequently used built-in string constants:
vbTab, vbCrLf
vbTab contains a string that does the same thing as
the Tab key on your keyboard, while vbCrLf creates a
character return and a line feed(similar to the Enter
key):

Print "Jack:" & vbTab & "1 pie" & vbCrLf &
"me:" & vbTab & "10 pies"

Will print:

Jack: 1 pie
me: 10 pies

To include special characters and quotation marks in


the strings, the Chr() function may be used:

Dim a As String
Print "A quotation mark: [" &
Chr(34) & "]"
a = "Replace 'apostrophes' for
quotation marks"
Replace( a, "'", Chr(34) )
Print a

Some string functions:


Str(),Val(),inStr(),Mid(),Replace(),Trim()
In fact there are tons of built-in string manipulation
functions available. But right now, I'll just introduce two:
Str() and Val().
Str() converts any numerical value into a string value
while Val() converts a string value into a numerical
value(only when it's convertible).
Dim MyString As String
Dim MyNumber As Single
MyString=Str(300) 'converts a
number into a string
MyNumber=Val("300") 'converts a
string into a number

Even if you don't do the conversion, you will not end up


getting Type Mismatch Errors. However, it is
considered better to use explicit type conversions,
because it is easier to debug.
Even if you do be prepared for next to impossible to
debug problems caused by VB refusing to convert
something and refusing to tell you what the heck it is.
VB is extremely touchy and raises an exception at the
least expected times.

Structure[edit]
An example definition of a structured type:

Type E2Point
x As Double
y As Double
End Type
Sub Test()
Dim MyPoint As E2Point
Dim MyPoint2 As E2Point
MyPoint.x = 4
MyPoint.y = -5
MyPoint2 = MyPoint 'Make a copy
MyPoint2.x = 3
MyPoint2.y = -6
Debug.Print MyPoint.x, MyPoint.y '4, -5:
not overriden with 3 and -6
Debug.Print TypeOf MyPoint Is E2Point
'True
Debug.Print TypeOf MyPoint Is Object
'False
End Sub

The type has to be defined outside of a procedure.


A variable of a structure type is not an object.
Links:

Type Statement, Office 2013, msdn.microsoft.com


Type Statement at Visual Basic for Applications
Reference, msdn.microsoft.com

Enumeration[edit]
An example definition of an enumerated type:

Enum Colors
Red '=0
Green '=1
Blue '=2
End Enum
Enum Colors2
Red2 = 1
Green2 '=2
Blue2 '=3
End Enum
Sub Test()
Debug.Print Red, Green, Blue
Debug.Print Red2, Green2, Blue2
Dim MyVar As Colors 'Ends up being typed
as Long
MyVar = 8 'Does not lead to an error: no
restriction on values
End Sub

Links:

Enum Statement, Office 2013, msdn.microsoft.com


Enum Statement at Visual Basic for Applications
Reference, msdn.microsoft.com

Type Test[edit]
To find out about the type of a variable, you can use
"TypeOf ... Is ..." test. The tested types can only be
object types and structure types, but the test can be
applied to any variable, whether typed as an integer, a
string or an object.
An example of TypeOf in Excel:
Set MyVar = Selection
Debug.Print "Selection is an object: " &
TypeOf MyVar Is Object
Debug.Print "Selection is a range: " &
TypeOf MyVar Is Range
Debug.Print "Sheets is of type Sheets: " &
TypeOf Sheets Is Sheets
MyStr = "Hello"
Debug.Print "Text is an object: " & TypeOf
MyStr Is Object
If TypeOf MyVar Is Range Then
Set MyCells = MyVar.Cells
End If

An example test with a "Select Case True":

Set MyVar = new Collection


Select Case True
Case TypeOf MyVar is Range
Debug.Print "Range"
Case TypeOf MyVar is Collection
Debug.Print "Collection"
Case Else
Debug.Print "Other cases"
End Select

You can further find out about a type


using IsObject and TypeName functions:

Debug.Print IsObject(Selection) 'True


Debug.Print IsObject("Hello") 'False
Debug.Print TypeName("Hello") 'String
Debug.Print TypeName(4) 'Integer
Debug.Print TypeName(3.5) 'Double
Debug.Print TypeName(Selection) 'Range