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.

Modules  Code in Visual Basic is stored in the form of modules. additional Forms are added and there may be a . As the application grows. The three kind of modules are Form Modules.  A simple application may contain a single Form. Standard Modules and Class Modules. and the code resides in that Form module itself.

. a separate module containing a procedure is created that implements the common code. This is a standard Module.  New objects can be created by writing code in class modules.CLS filename extension) are the foundation of the object oriented programming in Visual Basic.  Class module (.Modules  To avoid the duplication of code.

. variable and DLL procedure declarations.Each module can contain: Declarations : May include constant. type. 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 . for example) . these are ! # % $ & @  Must not be a reserved word (that is part of the code. procedures. like Option. controls. constants.  May be as much as 255 characters long (but don't forget that somebody has to type the stuff!). and so on:  A name must begin with a letter.variables.  Must not contain a space or an embedded period or type-declaration characters used to specify a data type.

although legal. should be avoided because it may be confused with the minus sign. Instead of First-name use First_name or FirstName. . The dash.

a data type is supplied for it that determines the kind of data they can store. double. long. date/time or string data.  When a variable is declared.Data types in Visual Basic 6  By default Visual Basic variables are of variant data types. The variant data type can store numeric. byte and boolean. . string.  The fundamental data types in Visual Basic including variant are integer. single. currency.

147.(+ 32.4x1038) Store large floating value which exceeding the single data type value store monetary values.468) .(+ 2.4x10-38) .(+ 3.767) Store integer values in the range of (2.468) Store floating point value in the range of (-3.147.768) .483. It supports 4 digits to the right of decimal point and 15 digits to the left Single Double Currency .483.Numeric Byte Integer Long Store integer values in the range of 0 255 Store integer values in the range of (32.

Dim MyString As String * 10 MyString = "Chilkat" ' MyString contains "Chilkat " Print RTrim$(MyString) ' prints "Chilkat" . A variable length string can store approximately 4 billion characters  Ex.String  Use to store alphanumeric values.

or date and time values. . 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  Ex. Use the Date data type to contain date values.Date  Use to store date and time values. 0001.  The default value of Date is 0:00:00 (midnight) on January 1.

Values are internally stored as -1 (True) and 0 (False) and any non-zero value is considered as true.Boolean  Boolean data types hold either a true or false value.  Dim runningVB As Boolean ' Check to see if program is running on Visual Basic engine. These are not stored as numeric values and cannot be used as such. If scriptEngine = "VB" Then runningVB = True End If .

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

Operators in Visual Basic Operators + / \ * ^ Mod & Description Add Substract Divide Integer Division Multiply Exponent (power of) Remainder of division String concatenation 5+5 10-5 25/5 20\3 5*4 3^3 20 Mod 6 "George"&" "&"Bush" Example 10 5 5 6 20 27 2 "George Bush" Result .

Relational Operators Operators > < >= <= <> = Description Greater than Less than Greater than or equal to Less than or equal to Not Equal to Equal to 10>8 10<8 20>=10 10<=20 5<>4 5=7 Example True False True True True False Result .

Logical Operators Operators OR AND Description Operation will be true if either of the operands is true Operation will be true only if both the operands are true .

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer: Get 4 months of Scribd and The New York Times for just $1.87 per week!

Master Your Semester with a Special Offer from Scribd & The New York Times