| | |
dynamic 2 dimensional array in vb 6
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2007
Posts: 3
Reputation:
Solved Threads: 0
how to declare dynamic 2 dimensional array in vb with one of the bounds variable ..
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
dim x(1 to i,1 to 4) as variant 'i is a variable
•
•
Join Date: Aug 2006
Posts: 20
Reputation:
Solved Threads: 1
You can do that by Redim statement
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 arTemp falls under this category. However, arTemp1 you can redimension the array in any dimension, but the contents will be erased with every Redim statement
Sub Array_Dimensioning()
Dim arTemp() As Integer ' Preserved Array
Dim arTemp1() As Integer ' Array without Preserve
ReDim Preserve arTemp(1, 1)
ReDim arTemp1(1, 1)
arTemp(1, 1) = 1
ReDim Preserve arTemp(1, 2)
arTemp(1, 2) = 2
ReDim Preserve arTemp(1, 3)
arTemp(1, 3) = 3
ReDim Preserve arTemp(2, 3)
ReDim arTemp1(2, 1)
End Sub
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 arTemp falls under this category. However, arTemp1 you can redimension the array in any dimension, but the contents will be erased with every Redim statement
![]() |
Similar Threads
- Need Help With two-dimensional array (VB.NET)
- two dimensional array (C)
- 2 dimensional array class (C)
- multi dimensional array search xml parser (PHP)
- dynamic allocation of 2d array (C)
- Need help passing a multi-dimensional array (C++)
- Trying to create a method to convert string letters into a two dimensional array (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: creating queries IN ACCESS using variables IN VB
- Next Thread: find the error pls...
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





