Home » VB 6.0 Tutorial » VB 6 Arrays

VB 6 Arrays

The VB 6 arrays hold data of a single type. In this article, you will learn about declaring, assigning, and various array handling techniques.

Types of  VB 6 Array

You can divide VB 6 arrays into two sets – One-dimensional array and .Multi-dimensional arrays The VB 6 can have a maximum of 60 dimensions. The arrays in Vb 6 are also classified based on keywords used to declare them:

  1. Regular arrays – It is declared using keyword Dim whole values remain variable.
  2. Dynamic arrays – A standard array can be expanded for more space, hence, it is called dynamic array. You can use keyword – ReDim to redeclare the array.
  3. Static arrays – A static variable does change its value after exiting a procedure in which they were declared. static arrays do the same and retain their value between procedure calls.
  4. Private arrays – The scope is limited to the procedure in which it is defined. Use the keyword – Private to define the procedure.
  5. Public arrays – The scope is an entire program or module. Use the keyword Public in the module.
  6. Type arrays – This is for user-defined array types

Regular Arrays

The regular arrays are the usual way of declaring an array using the Dim statement. The syntax to declare a regular array is given below:

Dim [WithEvents]  variable_name [(Subscripts)] [As [New] type] [, [WithEvents] variable2_name [(Subscripts)] [As [New] type] ...
  • WithEvents – This is an optional parameter and it is required when the variable is an object-variable type. An object-variable is used in modules with class or class modules.
  • Variable_name – It is the user-defined name of the variable.
  • Subscripts – They are optional parameters. An integer value subscript value indicates the number of members in an array. There are two ways to declare subscript:
               [lower To] upper

Example:

             TotalAmount( 10 To 20)
  •  New – This is an optional parameter and required only when the variable is object-variable type.
  • tpye- Defines the variable type which can be one of the following: Byte, Boolean, Currency, Long, Double, Single, String and Date.

Example:

Regular Array Declarations
Regular Array Declarations

Assigning Values to Regular Array Elements

To assign values to array elements refer to them using an index and then assign value like any normal variable.

(adsbygoogle = window.adsbygoogle || []).push({}); </script

Please support us by disabling your adblocker or whitelist this site from your adblocker. Thanks!

turn of adblocker imag

(adsbygoogle = window.adsbygoogle || []).push({});