VB.Net - Populating Arrays - arrays

So, I have this code below that populates an array.
Module Module1
Sub Main()
Dim n(10) As Integer
Dim i, j As Integer
For i = 0 to 10 step 3
n(i) = i + 100
Next i
For j = 0 to 10
Console.WriteLine("Element({0}) = {1}", j, n(j))
Next j
Console.ReadLine()
End Sub
End Module
I' am wondering why does the output of the code
is
Element({0}) = 100
Element({1}) = 0
Element({2}) = 0
Element({3}) = 103
Element({4}) = 0
Element({5}) = 0
Element({6}) = 106
Element({7}) = 0
Element({8}) = 0
Element({9}) = 109
What I intented to is this
Element({0}) = 100
Element({1}) = 103
Element({2}) = 106
Element({3}) = 109
Element({4}) = 112
Element({5}) = 115
Element({6}) = 118
Element({7}) = 121
Element({8}) = 124
Element({9}) = 127
Thank you in advance!!

Instead of using Step 3, move 3 to next line:
For i = 0 to 10
n(i) = 3 * i + 100
Next i
If anything is unclear, feel free to ask me.
(Edit: I see this was answered in comments, I did not read them before.)

Related

Getting memory Address like values of my array when printing (C programming)

I am trying to create 8x8 array, but when I am printing that array, after [7][7] Element I am not getting the exact values that I assigned while creating the array.
My array is a follows
#include <stdio.h>
int main() {
int puzzle[8][8] = {
// 0 1 2 3 4 5 6 7 8
{0,0,2,0,4,0,5,9,3},//0
{7,0,0,3,1,0,4,0,8},//1
{4,0,0,8,0,5,1,0,2},//2
{8,3,0,2,0,0,0,0,0},//3
{0,9,6,0,0,0,3,5,0},//4
{0,0,0,0,0,4,0,8,6},//5
{3,0,1,5,0,9,0,0,7},//6
{6,0,5,0,2,8,0,0,1},//7
{0,4,0,0,7,0,6,0,0} //8
};
for (int i = 0; i < 9; ++i)
{
for (int j = 0; j < 9; ++j)
{
printf("\n puzzle[%d][%d] = %d",i,j,puzzle[i][j]);
}
}
return 0;
}
and I am getting output as
puzzle[0][0] = 0
puzzle[0][1] = 0
puzzle[0][2] = 2
puzzle[0][3] = 0
puzzle[0][4] = 4
puzzle[0][5] = 0
puzzle[0][6] = 5
puzzle[0][7] = 9
puzzle[0][8] = 7
puzzle[1][0] = 7
puzzle[1][1] = 0
puzzle[1][2] = 0
puzzle[1][3] = 3
puzzle[1][4] = 1
puzzle[1][5] = 0
puzzle[1][6] = 4
puzzle[1][7] = 0
puzzle[1][8] = 4
puzzle[2][0] = 4
puzzle[2][1] = 0
puzzle[2][2] = 0
puzzle[2][3] = 8
puzzle[2][4] = 0
puzzle[2][5] = 5
puzzle[2][6] = 1
puzzle[2][7] = 0
puzzle[2][8] = 8
puzzle[3][0] = 8
puzzle[3][1] = 3
puzzle[3][2] = 0
puzzle[3][3] = 2
puzzle[3][4] = 0
puzzle[3][5] = 0
puzzle[3][6] = 0
puzzle[3][7] = 0
puzzle[3][8] = 0
puzzle[4][0] = 0
puzzle[4][1] = 9
puzzle[4][2] = 6
puzzle[4][3] = 0
puzzle[4][4] = 0
puzzle[4][5] = 0
puzzle[4][6] = 3
puzzle[4][7] = 5
puzzle[4][8] = 0
puzzle[5][0] = 0
puzzle[5][1] = 0
puzzle[5][2] = 0
puzzle[5][3] = 0
puzzle[5][4] = 0
puzzle[5][5] = 4
puzzle[5][6] = 0
puzzle[5][7] = 8
puzzle[5][8] = 3
puzzle[6][0] = 3
puzzle[6][1] = 0
puzzle[6][2] = 1
puzzle[6][3] = 5
puzzle[6][4] = 0
puzzle[6][5] = 9
puzzle[6][6] = 0
puzzle[6][7] = 0
puzzle[6][8] = 6
puzzle[7][0] = 6
puzzle[7][1] = 0
puzzle[7][2] = 5
puzzle[7][3] = 0
puzzle[7][4] = 2
puzzle[7][5] = 8
puzzle[7][6] = 0
puzzle[7][7] = 0
puzzle[7][8] = -445142480
puzzle[8][0] = -445142480
puzzle[8][1] = 32765
puzzle[8][2] = 480800256
puzzle[8][3] = -129200335
puzzle[8][4] = 0
puzzle[8][5] = 0
puzzle[8][6] = -2108403533
puzzle[8][7] = 32522
puzzle[8][8] = -2106304992
As you can see I am not getting exact values that I assigned to [7][8]th position.
The output I am getting looks like address or ids. I am not getting why it is happening, is it ide problem or is there any mistake in my code?
As you already seem to understand, array elements are indexed beginning at position zero. So when you define an array of size n arr[n], you can only hold n elements(0 to n - 1) in this array. Same applies for multi-dimensional arrays.
In your case you have only defined an array of size 8x8 which can hold only 64 elements. But you are trying to assign 9x9 81 elements to your array. Thus, only indices puzzle[0][0] to puzzle[7][7] are accessible.
The compiler shall issue a message for this initialization
int puzzle[8][8] = {
// 0 1 2 3 4 5 6 7 8
{0,0,2,0,4,0,5,9,3},//0
{7,0,0,3,1,0,4,0,8},//1
{4,0,0,8,0,5,1,0,2},//2
{8,3,0,2,0,0,0,0,0},//3
{0,9,6,0,0,0,3,5,0},//4
{0,0,0,0,0,4,0,8,6},//5
{3,0,1,5,0,9,0,0,7},//6
{6,0,5,0,2,8,0,0,1},//7
{0,4,0,0,7,0,6,0,0} //8
};
because elements of the array are arrays with 8 elements bur you are supplying 9 initializers for each element.
And if an array has N elements then the valid range of indices is [0, N).

Matlab - Subtract 1 vector with another in struct array

I have to different struct arrays(In the same Matlab file), what I want is to take 1 parameter/vector from a variable in a struct array and subtract it with different parameters from another variable in another struct array, is this possible?
Here is a small part of my code:
Dist(1).name = 'Pristina'
Dist(1).KM_To_Fushe_ks = 13.7 % 199-13.7 =
Dist(1).KM_to_Lipjan = 8.7 % 199-8.7 =
Dist(1).KM_to_Sllatina = 4.2 % 199-4.2 =
Dist(1).KM_to_Hajvali = 3.5 % 199-3.5 =
Dist(1).KM_to_Mitrovica = 46.9 % 199-46.9 =
Dist(1).KM_to_Anija = 1.9 % 199-1.9 =
EV(1).name = 'Nissan Leaf 24 kWh pack'
EV(1).RangeInKM_By_Manufacturer = 199 %SUBTRACT this with parameters above:
EV(1).Battery_Capacity = 21.6
EV(1).Battery_Warranty_KM = 100000
EV(1).Battery_Warrany_Year = 5
EV(1).EnginePower_Kw = 80
EV(1).EnginePower_hK = 109
EV(1).Torque_in_NewtonMeter = 254
EV(1).QuickCharging_type = 'CHAdeMO'
EV(1).QuickChargingEffect_kW_DC = 50
EV(1).NormalCharging_OnBoard_kW_AC = 3.3
EV(1).Seats = 5
EV(1).Luggage_in_Liters = 370
EV(1).Consumption_Mixed_kWh_per_10km_NEDC = 1.5
EV(1).Weight_Without_Driver = 1475
EV(1).TopSpeed_KM_per_hour = 144
EV(1).Acceleration_0to100KM_per_hour = 11.5
EV(1).RangeInKM_By_Manufacturer_RANK = 10
What I want is to have the number off 199 as a vector, and substract it by all these numbers = [13.7, 8.7, 4.2, 3.5, 46.9, 1.9]
How to do this?
Maybe I misinterpret your question, but this seem to work:
EV(1).RangeInKM_By_Manufacturer = 199 - Dist(1).KM_To_Fushe_ks
In the line you quote in your question, you left the initialization of KM_To_Fushe_ks after the difference; in short, you cannot have to vaiable assignements in the same command.
Also, if you end your lines with semi-colons you will suppress the output to the command window. Like this:
Dist(1).name = 'Pristina';
Dist(1).KM_To_Fushe_ks = 13.7;
Dist(1).KM_to_Lipjan = 8.7;
% Etc...
Here is one solution to my problem:
distances = [KM_to_Fushe_KS, KM_to_Lipjan];
remainingrange = arrayfun(#(s) s.RangeInKM - distances, EV, 'UniformOutput', false)
Or I could do this:
remainingrange = cell(size(EV));
for evidx = 1:numel(EV)
remaingrange{evidx} = EV(evidx).RangeInKM - distances;
end
Another solution is doing is putting multiple distances in once matrix:
Example:
Towns = {'Town1', 'Town2', 'Town3', 'Town4'};
distances = [0 200 13.7 8.7;
200 0 13.3 9.3;
13.7 13.3 0 255;
8.7 9.3 255 0];
EVs = {'Nissan Leaf 24 kWh pack', 'Nissan Leaf 30 kWh pack'};
ranges = [199 250];
And then I can calculate distances as a 3D matrix:
remainingrange = permute(ranges, [1 3 2]) - distances;
remainingrange = bsxfun(#minus, permute(ranges, [1 3 2]), distances);
If I want to check if a EV has not enough range in KM, I could write:
tooFarForMyEV = find(remainingrange < 0)
[from, to, ev] = ind2sub(size(remainingrange), tooFarForMyEV);
lackingrange = table(Towns(from)', Towns(to)', EVs(ev)', remainingrange(tooFarForMyEV), 'VariableNames', {'From', 'To', 'EV', 'Deficit'})

MATLAB: Remove sub-arrays from a multidimensional array into an array of ones

I would like to construct a function
[B, ind] = extract_ones(A)
which removes some sub-arrays from a binary array A in arbitrary dimensions, such that the remaining array B is the largest possible array with only 1's, and I also would like to record in ind that where each of the 1's in B comes from.
Example 1
Assume A is a 2-D array as shown
A =
1 1 0 0 0 1
1 1 1 0 1 1
0 0 0 1 0 1
1 1 0 1 0 1
1 1 0 1 0 1
1 1 1 1 1 1
After removing A(3,:) and A(:,3:5), we have the output B
B =
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
which is the largest array with only ones by removing rows and columns of A.
As the fifteen 1's of B corresponds to
A(1,1) A(1,2) A(1,6)
A(2,1) A(2,2) A(2,6)
A(4,1) A(4,2) A(4,6)
A(5,1) A(5,2) A(5,6)
A(6,1) A(6,2) A(6,6)
respectively, or equivalently
A(1) A(7) A(31)
A(2) A(8) A(32)
A(4) A(10) A(34)
A(5) A(11) A(35)
A(6) A(12) A(36)
so, the output ind looks like (of course ind's shape does not matter):
ind = [1 2 4 5 6 7 8 10 11 12 31 32 34 35 36]
Example 2
If the input A is constructed by
A = ones(6,3,4,3);
A(2,2,2,2) = 0;
A(4,1,3,3) = 0;
A(1,1,4,2) = 0;
A(1,1,4,1) = 0;
Then, by deleting the minimum cuboids containing A(2,2,2,2), A(4,1,3,3), A(1,1,4,3) and A(1,1,4,1), i.e. after deleting these entries
A(2,:,:,:)
A(:,1,:,:)
Then the remaining array B will be composed by 1's only. And the ones in B corresponds to
A([1,3:6],2:3,1:4,1:3)
So, the output ind lists the subscripts transformed into indices, i.e.
ind = [7 9 10 11 12 13 15 16 17 18 25 27 28 29 30 31 33 34 35 36 43 45 46 47 48 49 51 52 53 54 61 63 64 65 66 67 69 70 71 72 79 81 82 83 84 85 87 88 89 90 97 99 100 101 102 103 105 106 107 108 115 117 118 119 120 121 123 124 125 126 133 135 136 137 138 139 141 142 143 144 151 153 154 155 156 157 159 160 161 162 169 171 172 173 174 175 177 178 179 180 187 189 190 191 192 193 195 196 197 198 205 207 208 209 210 211 213 214 215 216]
As the array needed to be processed as above is in 8-D, and it should be processed more than once, so can anyone give me opinions on how to composing the program doing this task fast?
My work so far [Added at 2 am (GMT-4), 2nd Aug 2017]
My idea was that I delete the sub-arrays with the largest proportion of zero one by one. And here is my work so far:
Inds = reshape(1:numel(A),size(A)); % Keep track on which 1's survive.
cont = true;
while cont
sz = size(A);
zero_percentage = 0;
Test_location = [];
% This nested for loops are for determining which sub-array of A has the
% maximum proportion of zeros.
for J = 1 : ndims(A)
for K = 1 : sz(J)
% Location is in the form of (_,_,_,...,_)
% where the J-th blank is K, the other blanks are colons.
Location = strcat('(',repmat(':,',1,(J-1)),int2str(K),repmat(',:',1,(ndims(A)-J)),')');
Test_array = eval(strcat('A',Location,';'));
N = numel(Test_array);
while numel(Test_array) ~= 1
Test_array = sum(Test_array);
end
test_zero_percentage = 1 - (Test_array/N);
if test_zero_percentage > zero_percentage
zero_percentage = test_zero_percentage;
Test_location = Location;
end
end
end
% Delete the array with maximum proportion of zeros
eval(strcat('A',Test_location,'= [];'))
eval(strcat('Inds',Test_location,'= [];'))
% Determine if there are still zeros in A. If there are, continue the while loop.
cont = A;
while numel(cont) ~= 1
cont = prod(cont);
end
cont = ~logical(cont);
end
But I encountered two problems:
1) It may be not efficient to check all arrays in all sub-dimensions one-by-one.
2) The result does not contain the most number of rectangular ones. for example, I tested my work using a 2-dimensional binary array A
A =
0 0 0 1 1 0
0 1 1 0 1 1
1 0 1 1 1 1
1 0 0 1 1 1
0 1 1 0 1 1
0 1 0 0 1 1
1 0 0 0 1 1
1 0 0 0 0 0
It should return me the result as
B =
1 1
1 1
1 1
1 1
1 1
1 1
Inds =
34 42
35 43
36 44
37 45
38 46
39 47
But, instead, the code returned me this:
B =
1 1 1
1 1 1
1 1 1
Inds =
10 34 42
13 37 45
14 38 46
*My work so far 2 [Added at 12noon (GMT-4), 2nd Aug 2017]
Here is my current amendment. This may not provide the best result.
This may give a fairly OK approximation to the problem, and this does not give empty Inds. But I am still hoping that there is a better solution.
function [B, Inds] = Finding_ones(A)
Inds = reshape(1:numel(A),size(A)); % Keep track on which 1's survive.
sz0 = size(A);
cont = true;
while cont
sz = size(A);
zero_percentage = 0;
Test_location = [];
% This nested for loops are for determining which sub-array of A has the
% maximum proportion of zeros.
for J = 1 : ndims(A)
for K = 1 : sz(J)
% Location is in the form of (_,_,_,...,_)
% where the J-th blank is K, the other blanks are colons.
Location = strcat('(',repmat(':,',1,(J-1)),int2str(K),repmat(',:',1,(ndims(A)-J)),')');
Test_array = eval(strcat('A',Location,';'));
N = numel(Test_array);
Test_array = sum(Test_array(:));
test_zero_percentage = 1 - (Test_array/N);
if test_zero_percentage > zero_percentage
eval(strcat('Testfornumel = numel(A',Location,');'))
if Testfornumel < numel(A) % Preventing the A from being empty
zero_percentage = test_zero_percentage;
Test_location = Location;
end
end
end
end
% Delete the array with maximum proportion of zeros
eval(strcat('A',Test_location,'= [];'))
eval(strcat('Inds',Test_location,'= [];'))
% Determine if there are still zeros in A. If there are, continue the while loop.
cont = A;
while numel(cont) ~= 1
cont = prod(cont);
end
cont = ~logical(cont);
end
B = A;
% command = 'i1, i2, ... ,in'
% here, n is the number of dimansion of A.
command = 'i1';
for J = 2 : length(sz0)
command = strcat(command,',i',int2str(J));
end
Inds = reshape(Inds,numel(Inds),1); %#ok<NASGU>
eval(strcat('[',command,'] = ind2sub(sz0,Inds);'))
% Reform Inds into a 2-D matrix, which each column indicate the location of
% the 1 originated from A.
Inds = squeeze(eval(strcat('[',command,']')));
Inds = reshape(Inds',length(sz0),numel(Inds)/length(sz0));
end
It seems a difficult problem to solve, since the order of deletion can change a lot in the final result. If in your first example you start with deleting all the columns that contain a 0, you don't end up with the desired result.
The code below removes the row or column with the most zeros and keeps going until it's only ones. It keeps track of the rows and columns that are deleted to find the indexes of the remaining ones.
function [B,ind] = extract_ones( A )
if ~islogical(A),A=(A==1);end
if ~any(A(:)),B=[];ind=[];return,end
B=A;cdel=[];rdel=[];
while ~all(B(:))
[I,J] = ind2sub(size(B),find(B==0));
ih=histcounts(I,[0.5:1:size(B,1)+0.5]); %zero's in rows
jh=histcounts(J,[0.5:1:size(B,2)+0.5]); %zero's in columns
if max(ih)>max(jh)
idxr=find(ih==max(ih),1,'first');
B(idxr,:)=[];
%store deletion
rdel(end+1)=idxr+sum(rdel<=idxr);
elseif max(ih)==max(jh)
idxr=find(ih==max(ih),1,'first');
idxc=find(jh==max(jh),1,'first');
B(idxr,:)=[];
B(:,idxc)=[];
%store deletions
rdel(end+1)=idxr+sum(rdel<=idxr);
cdel(end+1)=idxc+sum(cdel<=idxc);
else
idxc=find(jh==max(jh),1,'first');
B(:,idxc)=[];
%store deletions
cdel(end+1)=idxc+sum(cdel<=idxc);
end
end
A(rdel,:)=0;
A(:,cdel)=0;
ind=find(A);
Second try: Start with a seed point and try to grow the matrix in all dimensions. The result is the start and finish point in the matrix.
function [ res ] = seed_grow( A )
if ~islogical(A),A=(A==1);end
if ~any(A(:)),res={};end
go = true;
dims=size(A);
ind = cell([1 length(dims)]); %cell to store find results
seeds=A;maxmat=0;
while go %main loop to remove all posible seeds
[ind{:}]=find(seeds,1,'first');
S = [ind{:}]; %the seed
St = [ind{:}]; %the end of the seed
go2=true;
val_dims=1:length(dims);
while go2 %loop to grow each dimension
D=1;
while D<=length(val_dims) %add one to each dimension
St(val_dims(D))=St(val_dims(D))+1;
I={};
for ct = 1:length(S),I{ct}=S(ct):St(ct);end %generate indices
if St(val_dims(D))>dims(val_dims(D))
res=false;%outside matrix
else
res=A(I{:});
end
if ~all(res(:)) %invalid addition to dimension
St(val_dims(D))=St(val_dims(D))-1; %undo
val_dims(D)=[]; D=D-1; %do not try again
if isempty(val_dims),go2=false;end %end of growth
end
D=D+1;
end
end
%evaluate the result
mat = prod((St+1)-S); %size of matrix
if mat>maxmat
res={S,St};
maxmat=mat;
end
%tried to expand, now remove seed option
for ct = 1:length(S),I{ct}=S(ct):St(ct);end %generate indices
seeds(I{:})=0;
if ~any(seeds),go=0;end
end
end
I tested it using your matrix:
A = [0 0 0 1 1 0
0 1 1 0 1 1
1 0 1 1 1 1
1 0 0 1 1 1
0 1 1 0 1 1
0 1 0 0 1 1
1 0 0 0 1 1
1 0 0 0 0 0];
[ res ] = seed_grow( A );
for ct = 1:length(res),I{ct}=res{1}(ct):res{2}(ct);end %generate indices
B=A(I{:});
idx = reshape(1:numel(A),size(A));
idx = idx(I{:});
And got the desired result:
B =
1 1
1 1
1 1
1 1
1 1
1 1
idx =
34 42
35 43
36 44
37 45
38 46
39 47

Storing values from a loop in a function in Matlab

I am writing a function in Matlab to model the length of stay in hospital of stroke patients. I am having difficulty in storing my output values.
Here is my function:
function [] = losdf(age, strokeType, dest)
% function to mdetermine length of stay in hospitaal of stroke patients
% t = time since admission (days);
% age = age of patient;
% strokeType = 1. Haemorhagic, 2. Cerebral Infarction, 3. TIA;
% dest = 5.Death 6.Nursing Home 7. Usual Residence;
alpha1 = 6.63570;
beta1 = -0.03652;
alpha2 = -3.06931;
beta2 = 0.07153;
theta0 = -8.66118;
theta1 = 0.08801;
mu1 = 22.10156;
mu2 = 2.48820;
mu3 = 1.56162;
mu4 = 0;
nu1 = 0;
nu2 = 0;
nu3 = 1.27849;
nu4 = 0;
rho1 = 0;
rho2 = 11.76860;
rho3 = 3.41989;
rho4 = 63.92514;
for t = 1:1:365
p = (exp(-exp(theta0 + (theta1.*age))));
if strokeType == 1
initialstatevec = [1 0 0 0 0 0 0];
elseif strokeType == 2
initialstatevec = [0 1 0 0 0 0 0];
else
initialstatevec = [0 0 (1-p) p 0 0 0];
end
lambda1 = exp(alpha1 + (beta1.*age));
lambda2 = exp(alpha2 + (beta2.*age));
Q = [ -(lambda1+mu1+nu1+rho1) lambda1 0 0 mu1 nu1 rho1;
0 -(lambda2+mu2+nu2+rho2) lambda2 0 mu2 nu2 rho2;
0 0 -(mu3+nu3+rho3) 0 mu3 nu3 rho3;
0 0 0 -(mu4+nu4+rho4) mu4 nu4 rho4;
0 0 0 0 0 0 0;
0 0 0 0 0 0 0;
0 0 0 0 0 0 0];
Pt = expm(t./365.*Q);
Pt = Pt(strokeType, dest);
Ft = sum(initialstatevec.*Pt);
Ft
end
end
Then to run my function I use:
losdf(75,3,7)
I want to plot my values of Ft in a graph from from 0 to 365 days. What is the best way to do this?
Do I need to store the values in an array first and if so what is the best way to do this?
Many ways to do this, one straightforward way is to save each data point to a vector while in the loop and plot that vector after you exit your loop.
...
Ft = zeros(365,1); % Preallocate Ft as a vector of 365 zeros
for t = 1:365
...
Ft(t) = sum(initialstatevec.*Pt); % At index "t", store your output
...
end
plot(1:365,Ft);

Sort multidimensional array in VBScript

How can I "Sort" the multidimensional arrays based on the hole size parameter please?
eg: A simple example would be (Loaded from Text file):
> Liv1.HoleSize[0] = 22 Liv1.HoleX[0] = 250 Liv1.HoleY[0] = -55
> Liv1.HoleSize[1] = 14 Liv1.HoleX[1] = 750 Liv1.HoleY[1] = 0
> Liv1.HoleSize[2] = 22 Liv1.HoleX[2] = 900 Liv1.HoleY[2] = -55
must then result in :
> Liv1.HoleSize[0] = 14 Liv1.HoleX[0] = 750 Liv1.HoleY[0] = 0
> Liv1.HoleSize[1] = 22 Liv1.HoleX[1] = 250 Liv1.HoleY[1] = -55
> Liv1.HoleSize[2] = 22 Liv1.HoleX[2] = 900 Liv1.HoleY[2] = -55
As VBScript has no native sort, you'll have to roll your own sort, or to get a little help from friends.
If your task is to sort your input file (verbatim as given) to an output file in the specified order, sort.exe is your friend:
Dim sIn : sIn = "..\data\in00.txt"
WScript.Echo readAllFromFile(sIn)
WScript.Echo "-----------"
Dim sCmd : sCmd = "sort /+19 " & qq(resolvePath(sIn))
Dim aRet : aRet = goWSLib.Run(sCmd)
If aRet(0) Then
' handle error
Else
WScript.Echo aRet(2)
End If
output:
================================================================
Liv1.HoleSize[0] = 22 Liv1.HoleX[0] = 250 Liv1.HoleY[0] = -55
Liv1.HoleSize[1] = 14 Liv1.HoleX[1] = 750 Liv1.HoleY[1] = 0
Liv1.HoleSize[2] = 22 Liv1.HoleX[2] = 900 Liv1.HoleY[2] = -55
-----------
Liv1.HoleSize[1] = 14 Liv1.HoleX[1] = 750 Liv1.HoleY[1] = 0
Liv1.HoleSize[0] = 22 Liv1.HoleX[0] = 250 Liv1.HoleY[0] = -55
Liv1.HoleSize[2] = 22 Liv1.HoleX[2] = 900 Liv1.HoleY[2] = -55
================================================================
If something like that solves your problem, just say so, and we can talk the support code in the library functions.
If, however, you have (to) parse(d) the input file into a two-dimensional array, the best friend you can get is a disconnectes ADODB recordset:
Dim aData : aData = Split(Join(Array( _
"22 250 -55" _
, "14 750 0" _
, "22 900 -55" _
, "11 222 333" _
)))
Dim afData(3, 2)
Dim nRows : nRows = UBound(afData, 1)
Dim nCols : nCols = UBound(afData, 2)
Dim i, r, c
For i = 0 TO UBound(aData)
r = i \ nRows
c = i Mod (nCols + 1)
afData(r, c) = aData(i)
' WScript.Echo i, r, c, aData(i)
Next
For r = 0 To nRows
For c = 0 To nCols
WScript.StdOut.Write vbTab & afData(r, c)
Next
WScript.Echo
Next
WScript.Echo "-----------------"
Dim oRS : Set oRS = CreateObject("ADODB.Recordset")
For c = 0 To nCols
oRS.Fields.Append "Fld" & c, adInteger
Next
oRS.Open
For r = 0 To nRows
oRS.AddNew
For c = 0 To nCols
oRS.Fields(c).value = afData(r, c)
Next
oRS.UpDate
Next
oRS.Sort = "Fld0"
WScript.Echo oRS.GetString(adClipString, , vbTab, vbCrLf)
WScript.Echo "-----------------"
oRS.Sort = "Fld2"
WScript.Echo oRS.GetString(adClipString, , vbTab, vbCrLf)
output:
========================================
22 250 -55
14 750 0
22 900 -55
11 222 333
-----------------
11 222 333
14 750 0
22 250 -55
22 900 -55
-----------------
22 250 -55
22 900 -55
14 750 0
11 222 333
========================================
Again: if that looks promising, we can discuss how to adapt/streamline this proof of concept code to your needs.

Resources