wildfire1982 Posted November 14, 2003 Posted November 14, 2003 I have a 2d Array and i need to increase the first dimension. Is this possible? I cant seem to get it to do it. I dont really want to have to change all of the code but if there isnt another way... i suppose i will have to. Ta very much. Chris Quote Chris
Leaders Iceplug Posted November 14, 2003 Leaders Posted November 14, 2003 Would switching your dimensional order work? i.e. (dimension1, dimension2) -> (dimension2, dimension1)? Other than that, the following works in VB6 and I'd assume that it works in .NET. Public Structure MyArray Public Elements() As Integer End Structure Public DualResizeArray() As Integer And then, you can resize each dynamic array with Redim. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
mocella Posted November 14, 2003 Posted November 14, 2003 Depends on if you're trying to preserve your data, in which case "redim preserve" won't do the trick. Otherwise, you'll have to make a new array and copy the original array members into the new array, which "preserve" is doing behind the scenes anyhow (creating a new array). Here's from MSDN: ReDim releases the existing array and creates a new array with the same rank. The elements of the new array are initialized to the default value for their data type unless you specify Preserve. If you include the Preserve keyword, Visual Basic copies the elements from the existing array to the new array. When you use Preserve, you can resize only the last dimension of the array, and for every other dimension you must specify the same size it already has in the existing array. For example, if your array has only one dimension, you can resize that dimension and still preserve the contents of the array, because it is the last and only dimension. However, if your array has two or more dimensions, you can change the size of only the last dimension if you use Preserve. Quote
wildfire1982 Posted November 17, 2003 Author Posted November 17, 2003 Thanks very much folks, looks like im changing it. Never mind, it will take a while but i suppose i should have looked first. Thanks again Quote Chris
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.