skyyakal Posted October 29, 2003 Posted October 29, 2003 (edited) STRUCTURE with arrays - Problem writing to arrays!!! Please help! Good afternoon Gentlemen, my problem is the following: I coded following structure + array of that structure Structure CardValueStructure Dim Value() As Integer Dim Scenario_ID() As Integer End Structure Shared CardValueArray(0) As CardValueStructure .... ReDim Preserve CardValueArray(2) CardValueArray(1).Value(0) = 5 The Line CardValueArray(1).Value(0) = 5 produces an error message I never saw in my life (tons of line codes in a MsgBox-like Form showing different .dll files that went wrong or something... have no idea). Would anybody know what is wrong with this code? Is there any other way to declare a structure with two dynamic arrays inside? Thanks a lot for your time and statements! skyyakal Edited November 27, 2005 by PlausiblyDamp Quote
*Experts* Nerseus Posted October 29, 2003 *Experts* Posted October 29, 2003 If VB.NET is like C#, you'll have to set each array inside the struct to a valid array, maybe something like this: Structure CardValueStructure Dim Value() As Integer Dim Scenario_ID() As Integer End Structure Shared CardValueArray(0) As CardValueStructure .... ReDim Preserve CardValueArray(2) [b]ReDim CardValueArray(1).Value(1)[/b] CardValueArray(1).Value(0) = 5 The change above shows a redim of the Value member of the struct. Your original code redim'd the CardValueArray variable, but each instance's Value and Scenario_ID members are still empty (undim'd) arrays. I hope my syntax is right, or that you can fix it if it's wrong :) -Ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
skyyakal Posted October 29, 2003 Author Posted October 29, 2003 Thank you Nerseus! I will try and post my results. Quote
skyyakal Posted October 29, 2003 Author Posted October 29, 2003 Nerseus, your code works just fine!!! Thank you 1000 times! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.