Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27221

excluding X number of lines while building a string in a Loop

$
0
0
I have to reconcile 2 columns of data that are built using a loop

Typically, the loop just gets everything fed into it. if incoming data had 50 lines, the loop will record them all

eg

Code:

Do While some.condition

string = string & new.line & ","

Loop

however, i dont want to begin building that string until the Xth line, or i might not want the last X lines

lets say the incoming data has 50 lines (but i wont know exactly). but i do know i want to pass on the first X lines and *then* begin to build the string

eg

incoming is

100
200
125
500
490
222
326
777


if i fed this into the loop the normal result would be:


100,200,125,500,490,222,326,777


but lets say i do not want the first 3 to be recorded. so when i run the loop, i have some code that records everything after the first 3 lines, so the result will be:

500,490,222,326,777


And the same for the end of the string built by the loop, but for the *last* X number of lines. so if i dont want the *last* 3 instead of:

100,200,125,500,490,222,326,777


i will get

100,200,125,500,490

so what i have now are two strings, or they can be two sets of integers (preferable) that are in sync with each other, wherein i can do a little math:

500 - 100
490 - 200
222 - 125
326 - 500
777 - 490

Viewing all articles
Browse latest Browse all 27221

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>