Can anyone suggest me a sample piece of VB.Net for FOR Each Statement or IF statement, which i could assign it in a Assign Activity…?
Implementing an IF statement inside an Assign Activity would be easy to implement using the if ternary operator, which looks something like this: If( [argument1,] argument2, argument3 )
Basically, the first argument is a boolean value and the value returned by this expression is the second argument if the first value is true or the third value otherwise.
For example, if I wanted to use the if operator in order to calculate the greater of two numbers, I would use something like this:
result = if(x>y,x,y)
You can find an in-depth article about it here: https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/if-operator
If you want to use a foreach-like instruction that can be used in an Assign and which would return a value (or a subset of values from the initial collection), I would suggest using LINQ. It has a really simple syntax and can be used with Lists, DataTables, Arrays ( and any other classes that implement the IEnumberable interface)
As an example, lets assume that I have a datatable and I want to get all the value from the first column of all the rows that have a particular value on the second column. Then, I would use an expression like this:
result = (From row As DataRow In DataTableDT.AsEnumerable() Where (row(1).ToString = "myValue" ) Select x = row(0) ).ToArray
The above example returns an array of string.
It might look intimidating at first but its quite easy to understand once you study the syntax a bit, especially if you have some general programming knowledge.
You can read more about Linq here: https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/linq/introduction-to-linq