converting vba to vb.net 2003

Associate
Joined
27 Jan 2005
Posts
1,396
Location
S. Yorks
Got a program that I need to convert from excel vba to vb.net2003 all is going reasonably ok apart from:

Private Type Leave
a as string
b as string
c as string
d() as double
e() as long
end type

Further in the code d and e are redimensioned with e being a 2 dimensional array.

Now I have converted it to

Private Structure Leave
a as string
b as string
c as string
d() as double
e() as long
end structure

but I can't redimension the e which is a 2 dimensional array.

I can't set the dimensions within the structure so need to do it outside of this.

How can I do this?

regards,

Matt
 
Last edited:
What error message are you getting? Is it a Redim Preserve or just a Redim you're doing? Redim should be fine, Redim Preserve only works on the first element of a multidimensional array.

It's been a long time since I've worked with VB or VBA, so I'm pretty rusty.
 
I get an error saying 'Redim' cannot change the number of dimensions of an array.

Am using the command "Redim leave.e(4,1)

Effectively I want to end up with a structure like:

Leave
-a
-b
-c
-d
--1
--2
--3
--4
--5
e
-1
--0,0
--0,1
-2
--1,0
--1,1

and so on and so forth.


regards,

matt
 
Ah right that's not going to work then, is it ever going to expand larger than 2 elements? You're gonna have to let it know upfront how many elements you're gonna be working with I think
 
Have tried that but get an error message stating "Arrrays declared as structure members canot be declared with an initial size"

regards,

matt
 
Ugh VB why do you have to be so illogical. I just got a pal to test the following in VB.net and he said it worked fine.

Private Structure Leave
a as string
b as string
c as string
d() as double
e(,) as long
Sub New(ByVal i As Integer)
ReDim e(i, i)
End Sub
End Structure
 
Thanks for that, it gives me a similar structure to what I want will have a play to see if I can alter it some more.


regards,

Matt
 
Back
Top Bottom