473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ReDim statements can no longer be used to declare array variables

inside a procedure , i code
Dim values(1) As Object

.... various other lines of code ...

ReDim values(2) As Object
According to the docs , I should be able to do this ...

However , I receive the compile-time message "ReDim statements can no longer
be used to declare array variables."


Nov 20 '05 #1
6 7463
Right - you have to code:

Dim values() As Object

.... various other lines of code ...

ReDim values(2) As Object

You can't declare it as a 2 element fixed size array and then resize
it as a 3 element array. You have to declare it without fixed size.
(In VB6 you used to be able to declare an array with the ReDim
statement - ugliness heaped on top of ugliness.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #2
Hi John,

Instead of using the fixex array have a look to the arraylist which is much
easier to handle.

http://msdn.microsoft.com/library/de...ClassTopic.asp

I hope this helps?

Cor
Nov 20 '05 #3
"John A Grandy" <johnagrandy-at-yahoo-dot-com> schrieb:
Dim values(1) As Object

... various other lines of code ...

ReDim values(2) As Object


Simply remove the 'As Object' from the 'ReDim' line. If you don't want to
loose the values stored in the array, use 'ReDim Preserve'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #4
> Herfried K. Wagner [MVP]wrote:
"]"John A Grandy" <johnagrandy-at-yahoo-dot-com> schrieb:
Dim values(1) As Object

... various other lines of code ...

ReDim values(2) As Object

Simply remove the 'As Object' from the 'ReDim' line. If you don't
want to
loose the values stored in the array, use 'ReDim Preserve'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>[/quote:3971f5bfa1]

I didn't know you could redim a fixed size array...
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #5
* ji************@yahoo-dot-ca.no-spam.invalid (Jimi) scripsit:
[...]

That will work now.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6
* ji************@yahoo-dot-ca.no-spam.invalid (Jimi) scripsit:
[...]

That will work now.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Nathan Sokalski | last post by:
I have an Array that I will be resizing with the ReDim statement. For some reason that I cannot figure out, I am recieving the following error: The code that this occurs in is as follows: ...
8
by: John A Grandy | last post by:
redim may no longer be used in vb.net ... is there another way to change at the runtime the lower & upper bounds of an array ?
5
by: Zenobia | last post by:
Hello, I want to keep a list references to database records being accessed. I will do this by storing the record keys in a list. The list must not contain duplicate keys. So I check the...
9
by: John A Grandy | last post by:
In VB6 you could get away with the following code: Dim Index As Integer Dim ItemsCount As Integer Dim StringArray() As String Dim StringValue As String '....
6
by: Adrian | last post by:
Hi In VB 6 I would declare an array in the general part to make it visible to all parts then once I know how elements I had I would redim it with the amount thus Dim testarray() as string ...
19
by: Tom Jastrzebski | last post by:
Hello, I was just testing VB.Net on Framework.Net 2.0 performance when I run into the this problem. This trivial code attached below executed hundreds, if not thousand times faster in VB 6.0...
2
by: Fredrik Strandberg | last post by:
I have not been able to find the solution of this problem anywhere: I am building a class PrivateHelper that provides methods to access private members and invoke private methods, to be used for...
9
by: Anil Gupte | last post by:
I am having a problem using Multidim arrays. I want to create an array which as I understand it is dimensioned as: dim xyz (rows,columns) as String I want to populate it with rows from a...
1
by: jroper73 | last post by:
I need to create a dynamic array of structure. Here is some of my code <script language="VB" runat="server"> Structure PlayerStructure Dim Name As String Dim MoreCrap as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.