Visual Basic 6 (VB6) Data Types
Visual Basic 6 (VB6) Data Types
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. 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
Modules
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.
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:
(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)
avoided because it may be confused with the minus sign. Instead of First-name use First_name or FirstName.
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.
Numeric
Byte Integer Long
Single
Double Currency
String
Use to store alphanumeric values. A
variable length string can store approximately 4 billion characters Ex. Dim MyString As String * 10 MyString = "Chilkat" ' MyString contains "Chilkat " Print RTrim$(MyString) ' prints "Chilkat"
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 Ex. Use the Date data type to contain date values, time values, or date and time values. The default value of Date is 0:00:00 (midnight) on January 1, 0001.
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. Dim runningVB As Boolean ' Check to see if program is running on Visual Basic engine. If scriptEngine = "VB" Then runningVB = True End If
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. Ex. Dim A Dim A as Variant
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