-
Im trying to make a dynamic nested Type stucture like this.
Type Var2_t
End Type
Type Var1_t
Stuff() As Var2_t
End Type
Dim Var1() As Var1_t
I can't figure out how to redim this.
I tryed:
ReDim Var1(number).Stuff(number)
But it doesn't work. When i fill the Type with values from a File it says "Out of memory". But if i was to make the
Stuff() Array fixed: stuff(314), it works just fine!
I want the Types to be dynamicly redim.
I hope you can help, i have been triying to figure this out for a while now.
Thanks
-
Yeuck... Very messy.
If I were you I would turn the whole thing into Classes and use Collections to store dynamic iterations of the sub-clases.
But thats just me ;)
-
What´? There's nothing wrong with nkads Type structure.
the "Out of memory" prob has occurred to me a month ago in a similar procedure. Actually it's not out of memory but that you read the UDT from the wrong position. The dynamic array inside the type is written with a 2 byte descriptor that is also read from a specific point in the file. When the file is corrupted or your writing procedure doesn't match the reading procedure, then the descriptor will get incorrect information and cause out of memory. Best solution is to look trough your code.
-
Actually kedaman, I am reading from the appropriate byte offset in the file. When I try to ReDim my array structures I get "Out of Memory". Actually what this is for is a Quake2 model viewer. It works to! Just not this.
Regarding using classes and collections, I really dont think that would work because the file is structured a certain way.
I dont know. I might just convert this into C, put it in a DLL and just be done with it.
-
Although, with C, be very careful with your alignment. It's capable of destroying your program completely, and you have no idea where it comes from.
-
Well, then there could of course be the real "Out of Memory" cause. Maybe you have too many apps running or your vb project is too large, since redimming type structure works just fine for me on any comp. I guess you could isolate and run that part of your app independently, or maybe you could just emulate that in a new project.