Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

C++ Equivalent to VB ReDim Preserve

Resizing arrays while preserving the existing contents is easily done in VB using ReDim Preserve.  In C++/CLI, you have other alternatives:

ReDim Preserve YourArray(1, 2)

C++/CLI (assuming an integer array):
array<int, 2> ^tempVar = gcnew array<int, 2>(2,3);
if (YourArray != nullptr)
    for (int Dim0 = 0; Dim0 < YourArray->GetLength(0); Dim0++)
        int CopyLength = System::Math::Min(YourArray->GetLength(1), tempVar->GetLength(1));
        for (int Dim1 = 0; Dim1 < CopyLength; Dim1++)
            tempVar[Dim0, Dim1] = YourArray[Dim0, Dim1];
YourArray = tempVar;

If you need to convert from VB to C++ and you are depending on the results being reliable and accurate, then you will want to have VB to C++ Converter, the best VB to C++ converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.