It is currently Wed Aug 05, 2020 2:53 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: [Done]ReDim
PostPosted: Thu Jan 09, 2020 6:21 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6254
Location: Wales, UK
From the Help:
Quote:
If ReDim is used with a multi-dimension array, only its last dimension can be changed.


That's fine, but there should be an example.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: ReDim
PostPosted: Thu Jan 09, 2020 10:34 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 1126
IdeasVacuum wrote:
If it sounds simple, you have not grasped the complexity.

Maybe I haven't grasped the complexity of your request. For me it sounds simple, even without an example :mrgreen:

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: ReDim
PostPosted: Fri Jan 10, 2020 12:38 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6254
Location: Wales, UK
... documentation should include an example of every function.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: ReDim
PostPosted: Fri Jan 10, 2020 8:48 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3734
Location: Utah, USA
Would something like this be to the gentleman's liking?
Code:
 Dim MyArray.l(1) ; We have 2 elements
  MyArray(0) = 1
  MyArray(1) = 2
 
  ReDim MyArray(4) ; Now we want 5 elements
  MyArray(2) = 3
 
  For k = 0 To 2
    Debug MyArray(k)
  Next

 ;Recreate the array with 2 dimensions and a total of 6 elements
 ;(2 columns × 3 rows). This will clear any previous contents.
 Dim MyArray(1, 2)

  Debug "---"
  For k = 0 To 2 ; row index
    For j = 0 To 1 ; column index
      Debug "(" + j + ", " + k + ") = " + MyArray(j, k)
    Next
  Next

  MyArray(0, 0) = 1
  MyArray(0, 1) = 2
  MyArray(1, 0) = 3
  MyArray(1, 1) = 4
  MyArray(2, 0) = 5
  MyArray(2, 1) = 6

  Debug "---"
  For k = 0 To 2 ; row index
    For j = 0 To 1 ; column index
      Debug "(" + j + ", " + k + ") = " + MyArray(j, k)
    Next
  Next

 ;Now we want to change the number of elements. We can only change
 ;the size of the last dimension. We change the lastdimension
 ;from 1 to 3 for a new total of 8 elements (2 columns x 4 rows).
 ReDim MyArray(1, 3)

  Debug "---"
  For k = 0 To 3 ; row index
    For j = 0 To 1 ; column index
      Debug "(" + j + ", " + k + ") = " + MyArray(j, k)
    Next
  Next

_________________
Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye