943,772 Members | Top Members by Rank

Ad:
Oct 8th, 2007
0

dynamic 2 dimensional array in vb 6

Expand Post »
how to declare dynamic 2 dimensional array in vb with one of the bounds variable ..
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. dim x(1 to i,1 to 4) as variant
  2. 'i is a variable
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
stargazr is offline Offline
3 posts
since Oct 2007
Oct 8th, 2007
0

Re: dynamic 2 dimensional array in vb 6

You can do that by 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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
shasur is offline Offline
20 posts
since Aug 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: creating queries IN ACCESS using variables IN VB
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: find the error pls...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC