Siebel VB Language Reference > Methods Reference for Siebel VB > Array Methods >

Declare Array Method


The Declare Array method allocates memory for a dynamic array to the dimensions that you specify. It does not return a value. You typically use the Dim statement to declare a dynamic array without specifying a size for it.

Format

ReDim [Preserve] arrayName (lower To upper) [As [New] type], ...

The following table describes the arguments that you can use with this method.

Argument
Description

arrayName

The name of the array to redimension.

lower

The lower boundary of the array. If you do not specify this argument, then Siebel VB uses 0 as the default value of the lower boundary. You can use the Set Array Lower Boundary method to modify this default value.

upper

The upper boundary of the array.

type

The data type of the array elements.

Usage

Note the following:

  • You can use the ReDim statement to declare an array in a procedure that has not previously been declared using the Dim statement or the Global statement. In this situation, you can declare no more than 60 dimensions.
  • As an option, you can use the Declare Array method to reset array elements.
  • You cannot use the Declare Array method at the module level. You must use it in a procedure.
  • The Preserve option modifies the last dimension in the array while maintaining the contents of the array. If you do not specify the Preserve option, then Siebel VB resets the contents of the array. It sets numbers to zero (0). It sets strings and variants to null ("").
  • If you do not include the As clause, then to specify the variable type, you can use a type character as a name suffix. You can use this clause and suffix in a single Declare Array method. YOu cannot use this clause and suffix on the same variable.
  • You must not redimension an array in a procedure that has received a reference to an element in the array in an argument. The result of this configuration is not predictable.
  • A dynamic array that you create with the Dim statement can include no more than eight dimensions. If you require more than eight dimensions, then you must use the Declare Array method. For information about declaring a dynamic array, see Dynamic Arrays.
Example

The following example determines the net present value for a series of cash flows. The array variable that holds the cash flow amounts is initially a dynamic array that this example redimensions after the user enters the number of cash flow periods:

Sub Button_Click
   Dim aprate as Single
   Dim varray() as Double
   Dim cflowper as Integer
   Dim x as Integer
   Dim netpv as Double
   Dim msgtext as string
   cflowper = 2
   ReDim varray(cflowper)
   For x = 1 to cflowper
      varray(x) = 4583
   Next x
   msgtext = "Enter discount rate:"
   aprate = 3.25
   If aprate > 1 then
      aprate = aprate / 100
   End If
   netpv = NPV(aprate,varray())
      msgtext = "The Net Present Value is: " (netpv, "Currency")
End Sub

Related Topics

Declare Variable Statement
Declare Global Variable Statement

Siebel VB Language Reference Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Legal Notices.