PDA

View Full Version : اررور در redim



just4froum
پنج شنبه 03 آذر 1390, 16:47 عصر
با سلام به همگی :

آیا کسی میدونه چرا برنامه از این دو خط ایراد میگیره ؟؟؟

ReDim Preserve x(0, 0, 24)
ReDim Preserve x(0, 1, 24)

مگه ما در قسمت بالا بر آرایه اضافه نکردیم ؟؟؟

ولی وقتی کلمه ی Preserve رو از خط دوم بر میداریم درست میشه ولی خوب اطلاعات قبل میپره !!!

با تشکر

butterfly8528
جمعه 04 آذر 1390, 01:18 صبح
سلام دوست عزیز .


You can use the ReDim statement repeatedly to change the number of elements and dimensions in an array. However, you can't declare an array of one data type and later use ReDim to change the array to another data type, unless the array is contained in a Variant. If the array is contained in a Variant, the type of the elements can be changed using an As type clause, unless you’re using the Preserve keyword, in which case, no changes of data type are permitted.

If you use the Preserve keyword, you can resize only the last array dimension and you can't change the number of dimensions at all. For example, if your array has only one dimension, you can resize that dimension 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 and still preserve the contents of the array. The following example shows how you can increase the size of the last dimension of a dynamic array without erasing any existing data contained in the array.

ReDim X(10, 10, 10)
. . .
ReDim Preserve X(10, 10, 15)

Similarly, when you use Preserve, you can change the size of the array only by changing the upper bound; changing the lower bound causes an error.

If you make an array smaller than it was, data in the eliminated elements will be lost. If you pass an array to a procedure by reference, you can't redimension the array within the procedure.

MSDN




موفق باشید :لبخندساده:.

just4froum
جمعه 04 آذر 1390, 12:13 عصر
پس نتيجه ميگيريم اين كار شدني نيست !!!

با تشكر

M.T.P
جمعه 04 آذر 1390, 12:27 عصر
پس نتيجه ميگيريم اين كار شدني نيست !!!

با تشكر

Preserve رو بردارید ، درست میشه
Preserve فقط اجازه تغییر سلول آخر رو میده

just4froum
جمعه 04 آذر 1390, 15:11 عصر
Preserve رو بردارید ، درست میشه
Preserve فقط اجازه تغییر سلول آخر رو میده

خوب مشکل من هم همینه اگه preserve رو بردارم اطلاعاتم میپره !!!

M.T.P
جمعه 04 آذر 1390, 15:37 عصر
خب اصلش همینه ، اول باید ساختار آرایه رو درست کنید بعد پرش کنید.
کدتون چی هست؟ شاید بشه یه فکری به حالش کرد!

just4froum
جمعه 04 آذر 1390, 17:46 عصر
با تشکر از جناب M.T.P :

خودم یه فکری براش کردم و مجبور شدم کل کدمو بریزم بهم.