[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 126
  • Last Modified:

variable size list array

I have a linked list of coordinates, called Coordinate_Dbl.  It contains an x and a y value.
type Coordinate_Dbl
  x as double
  y as double
end type

When I dimension it at the beginning of the function, I put (eg):

Dim tempCoordinate(7) as Coordinate_Dbl

But I can't set the number of elements in the array to:

Dim numofPoints as Integer
dim tempCoordinate(numofPoints) as Coordinate_Dbl

What do I do?
PS I am a bit hung over today, so I might be being stupid
1 Solution
The only way that you can dimension an array dynamically is as follows.

Inital Declaration as dynamic array
Dim tempCoordinate() as Coordinate_Dbl

Subsequently in a procedure /function

ReDim tempCoordinate(numofPoints)

With or without the Preserve keyword to retain values already assigned in the array elements.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now