You are on page 1of 5

Data Types

1. Numeric Types
A. Integer : Stores integer values in the range –32768 to +32768. Stored
using 2 bytes.
B. Long : Stores long integers in the range –2147483648 to 2147483647.
Stored using 4 bytes.
C. Single : Stores single precision floating point numbers. It can store
negative numbers in the range –3.40E38 to –1.40E-45 and positive
numbers in the range 1.40E-45 to 3.40E38. They are stored using 4 bytes.
D. Double : Stores double precision floating point numbers. Can store
negative numbers in the range –1.79E308 to –4.94E324 and positive
numbers in the range 4.94E-324 to 1.79E308. Stored using 8 bytes.
E. Currency : Stores fixed point numbers with 4 fractional digits. The
currency data type can represent numbers in the range –
922337203685477.5808 to 922337203685477.5807.
F. Byte : Data is stores as bytes and an individual byte can be accessed very
easily. The byte type basically holds an integer in the range of 0 to 255.
Bytes are frequently used to access binary files, image and sound files.

2. String Data Type


This type can store only text. Nearly 2 gigabytes of text can be stored in a string
variable. This type can also hold integers.
Fixed length strings : String variables have variable lengths. Their length depends
on the values assigned to them. A fixed length string can be specified by the
following declaration : Dim TextVar as String * 100 This variable can hold data
upto 100 characters. If a string with less than 100 characters is assigned to
TextVar then the variable is padded with spaces and if the assigned string
exceeds the max declared length, it is truncate.

3. Boolean Data type


This type stores True / False values.

4. Date Variables
These variables store Data and Time. They are double precision numbers : the
integer part represents date and fractional part represents the time.
Eg Dim Jdate as Date
Jdate = “03/01/2005”
Jdate = “03/01/2005 10:00:00 AM”
Jdate = #03/01/2005 10:00:00 AM#

5. Object Data Type


An object variable is a reference to one of the VB objects
Eg Dim a as CommandButton
Set a = Command1
a.Caption=”Save”
6. Variant Data Type
This is a special data type that can contain any kind of data except fixed length
String data and user defined types. A Variant can also contain the special values
Empty, Error, Null and Nothing. A variable declared as Variant is handled by VB
according to the variable’s current contents. If an integer is assigned to it, VB
treats it as an Integer and so on.
Sequence of Form Events

Initialize : This event is fired a form is loaded. This event is normally used to initialize
variables used in the form. In this event Form object is referenced.

Load : When a form is loaded into memory, either using load statement or show method
or by referencing a form property, the load event is triggered after Initialize event. This
event is fired only once for each form. Form object’s properties and controls are
referenced. VB creates the form window and its child controls.

Activate : The activate event is fired whenever the form becomes active window i.e. the
window is ready to accept user input. The form becomes the active window when the
user clicks the mouse on it or Show or SetFocus method is called.

Resize : This event is fired when the the form is resized or the window state is changed
by minimize, maximize or restore buttons. It is also fired the first time the form is
displayed.

Paint : The Paint event is fired when the Form’s AutoRedraw property is set to False. VB
requests the form to refresh itself the first time it is displayed and when another window
covers and then uncovers it.

Deactivate : This event is fired when the form looses the focus. Exactly opposite to
Activate event.

QueryUnload : When the form is closed or the form Unload method is called, this event
is fired, followed by Unload event. The QueryUnload event allows the option of
canceling the unloading of form by setting the Cancel parameter to True.

Unload : In this event, Clean up of objects and variables is done. Any remaining object
variable should be set to Nothing in this event.

Terminate : This is the final event that is fired for a form. It occurs when a form is set to
Nothing. This event indicates that VB has removed the form and its module from
memory.

vbFormControlMenu 0 The user chose the Close command from


the Control menu on the form.
vbFormCode 1 The Unload statement is invoked from
code.
vbAppWindows 2 The current Microsoft Windows operating
environment session is ending.
vbAppTaskManager 3 The Microsoft Windows Task Manager is
closing the application.
vbFormMDIForm 4 An MDI child form is closing because the
MDI form is closing.
vbFormOwner 5 A form is closing because its owner is
closing.

You might also like