Click here to Skip to main content
15,436,928 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

I have an array like

source array :
column1 column2 column3
aaa xyz 35
bbb xyz 45
ccc klm 30

I want to loop in array and then copy line-by-line to another array where the column2 value is xyz.

The result must be like this

destination array :
column1 column2 column3
aaa xyz 35
bbb xyz 45

Could you please help me how to code it in VB.NET?

Thanks ,

Create a new array setting it to the count of the current array.
Then, run a loop on the current array.
Using an if condition select only values that have xyz in them and then reassign them to the new one.

If you want to be more precise, run a loop on the current array, using the same if condition and a counter, get the count of those elements whose second value is xyz and then create a new array using this counter.
Share this answer
my real array has too many columns .. >100.
is there any easy way to copy line matching corresponding fields .

thank you very much .
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900