P Pantelis Member Licensed User Longtime User Jun 22, 2013 #1 Hi all. How to get the index of the last item of specific dimension of multidimensional array? For example in vb the code is: Code: Dim MyArray(5,5) as Integer For I = 0 to Ubound(MyArray , 1) For J = 0 to Ubound(MyArray , 2) 'Some code here Next J Next I What is the equivalent to Ubound in b4a? If i try Code: Dim MyArray( 6, 6) as Int For I = 0 to MyArray.Length -1 For J = 0 to MyArray.Length -1 'Some code Next Next MyArray.Length gives me the number of items of the first dimension only. How to get the length of the second or any other dimension of a multidimensional array?
Hi all. How to get the index of the last item of specific dimension of multidimensional array? For example in vb the code is: Code: Dim MyArray(5,5) as Integer For I = 0 to Ubound(MyArray , 1) For J = 0 to Ubound(MyArray , 2) 'Some code here Next J Next I What is the equivalent to Ubound in b4a? If i try Code: Dim MyArray( 6, 6) as Int For I = 0 to MyArray.Length -1 For J = 0 to MyArray.Length -1 'Some code Next Next MyArray.Length gives me the number of items of the first dimension only. How to get the length of the second or any other dimension of a multidimensional array?
agraham Expert Licensed User Longtime User Jun 22, 2013 #2 Look at TargetRank in the Reflection library Code: Dim r As Reflector Dim ranks(0) As Int r.Target = AnArray ranks = r.TargetRank ' ranks.Length is the number of dimensions of the array ' rank contents are the length of the first element of each dimension Upvote 0
Look at TargetRank in the Reflection library Code: Dim r As Reflector Dim ranks(0) As Int r.Target = AnArray ranks = r.TargetRank ' ranks.Length is the number of dimensions of the array ' rank contents are the length of the first element of each dimension