Showing posts with label Data Types. Show all posts
Showing posts with label Data Types. Show all posts

User-Defined Data Types in Visual Basic 6

Variables of different data types when combined as a single variable to hold several related informations is called a User-Defined data type.
A Type statement is used to define a user-defined type in the General declaration section of a form or module. User-defined data types can only be private in form while in standard modules can be public or private. An example for a user defined data type to hold the product details is as given below.

Private Type ProductDetails
ProdID as String
ProdName as String
Price as Currency
End Type

The user defined data type can be declared with a variable using the Dim statement as in any other variable declaration statement. An array of these user-defined data types can also be declared. An example to consolidate these two features is given below.

Dim ElectronicGoods as ProductDetails ' One Record
Dim ElectronicGoods(10) as ProductDetails ' An array of 11 records

Visual Basic 6 Data Types

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 LEARN MORE>>

Data Types

Data type is defined as the set of possible values a variable can hold. Data types in C++ can be divided into three categories:

  1. Built-in Data Type
  2. User Defined Data Type
  3. Derived Data Type

Built-in Data Types
The C++ compiler supports all the built-in data types. These data types are also known as standard data types and ae not composed of other data types. LEARN MORE>>