homecode zoneQuick Codedownloadssubmit codeabout usfeedbackscontact ussitemap
 
Beginners
Database
File System Object
General
Graphics
Multimedia
Networking
Shell Object
Timer
Array
Date/Time
Declaration
Error Handling
File/Folder
Logic
Loops & Conditional
Math
Miscellaneous
Strings
Values
Pro - Languages
C/C++
Java
Visual basic
asp
vb.net 2003/2005
asp.net
Quick Code
SUBMIT CODE
Mail List
LINKS
Submit LINK
 
ProgrammerGuide.net - VB Array.
Home » VB Zone » Array

Erase statement

Reinitializes the elements of fixed-size arrays and releases dynamic-array storage space
Syntax: Erase arraylist
The required arraylist argument is one or more comma-delimited array variables to be erased.

Remarks
Erase behaves differently depending on whether an array is fixed-size (ordinary) or dynamic. Erase recovers no memory for fixed-size arrays. Erase sets the elements of a fixed array as follows:

Type of Array Effect of Erase on Fixed-Array Elements
Fixed numeric array Sets each element to zero.
Fixed string array (variable length) Sets each element to a zero-length string ("").
Fixed string array (fixed length) Sets each element to zero.
Fixed Variant array Sets each element to Empty.
Array of user-defined types Sets each element as if it were a separate variable.
Array of objects Sets each element to the special value Nothing.

Example:
Erase sMessage
In a regular array, the Erase statement will simply initialize all the elements. (False for Boolean, 0 for numbers, and "" for strings). In a dynamic array, Erase will also release all the memory allocated to the array.

Dim

Dim statement placed right in the procedure where it's going to be used. The value of a procedure level variable cannot be accessed outside it's procedure. When the procedure finishes (End Sub or End Function), the variable is destroyed and memory allocated to the variable is released.

Example:
Dim Word As String

ReDim

Used at procedure level to reallocate storage space for dynamic array variables.
Syntax: ReDim [Preserve] varname(subscripts) [As type] [, varname(subscripts) [As type]] . . .

The ReDim statement syntax has these parts:

Part Description
Preserve Optional. Keyword used to preserve the data in an existing array when you change the size of the last dimension.
varname Required. Name of the variable; follows standard variable naming conventions.
subscripts Required. Dimensions of an array variable; up to 60 multiple dimensions may be declared. The subscripts argument uses the following syntax: [lower To] upper [, [lower To] upper]. When not explicitly stated in lower, the lower bound of an array is controlled by the Option Base statement. The lower bound is zero if no Option Base statement is present
type Optional. Data type of the variable; may be Byte, Boolean, Integer, Long, Currency, Single, Double, Decimal (not currently supported), Date, String (for variable-length strings), String * length (for fixed-length strings), Object, Variant, a user-defined type, or an object type. Use a separate As type clause for each variable being defined. For a Variant containing an array, type describes the type of each element of the array, but doesn't change the Variant to some other type.

Remarks
The ReDim statement is used to size or resize a dynamic array that has already been formally declared using a Private, Public, or Dim statement with empty parentheses (without dimension subscripts).

Example:
Dim X(10, 10, 10)
[Code]
ReDim Preserve X(10, 10, 15)

Viewers: 15
Visitors:127291
Last Updated on:Sunday, January 17, 2010
Home | About us | Feedback | Contact us | Sitemap
Copyright © 2008 ProgrammerGuide.net. All rights reserved.
This site is best viewed in IE 6.0, Firefox 1.5 and above with screen resolution of 1024 X 768.