Split a substring from String

Hi Everyone,
This is the output string read from three text files.
10
20
30
Trying to split the each substring from the above string and have to add the values.
inorder to get the each substring from the string , i tried this .


.

Im not sure how to split if the string is in this format:

For the first substring:
out_TextFile.SubString(out_TextFile.indexOf(0)).Split(Environment.NewLine.ToCharArray)(0)

I’m not 100% sure I follow. So your string is:

10
20
30

And you want to add up the numbers, correct? So you want an output to be 60?

If so, you should not be using the Substring method at all. Just split the string by newline into an array of strings, then use a for each activity to add each line.

For Each num in Strings.Split(out_TextFile,environment.newline)
If IsNumeric(num) Then
Assign SumOfTextFile = SumOfTextFile + cdouble(num)  //  This assumes SumOfTextFile is of type double. You could also have it be integer or decimal or whatever numeric type you prefer

This would iterate through each line and add them up (assuming the text is just a number).

If it’s possible your input text may contain letters and not just numbers on a plain line, then you may wish to use regex instead. The idea would be the same, but instead of iterating through an array of strings with strings.split() you would instead iterate through an array of regex matches found with regex.matches()

Hi @Dave Thanks for acknowledging my error. Wil try and work it out:)