Execute visual basic code

code

#1

I want to process a list of data in object type List<String> from namespace System.Linq.
The easiest would be to use Visual Basic methods .First(), .RemoveAt(0) and .Count()
However none of the activities seem to be able to simply execute code.

Can I include System.Linq and execute a script within the xaml?


#2

You can import System.Linq namespace (import tab after variables,arguements) and perform your logic. I think intellisense for linq is not available.


#3

Hi vvaidya
Where do I enter my lines of code?


#4

You can import Namespaces from bottom panel

Regards…!!
Aksh


#5

Thanks aksh :smiley: I got the import solved. But where then do I enter my script?
Edit: I am not expecting a full-fledged IDE like Eclipse, but just a text window or a box or something.


#6

Where you wants to use may be in some variable assignment? or in Iteration? It dependents on your need and now after importing all linq functions will be available for you to use here.


#7

TL:DR
No box I have tried can handle the line:
List<String>.Add(<String>)
E.g. the Assign box expects my method to return a variable.

I have loaded an Excel file into a dataTable and now I am looping over a column. I want to assign the row values to a list by using strList.Add(row), but the Assign box is not designed to allow that.
Later I will be referring to the strList variable from different places in my state machine. I want to process the first item and then call strList.RemoveAt(0) until all values have been processed and removed.


#8

I can also rephrase: I want to call a custom VB function.


Function hypotenuse(ByVal side1 As Single, ByVal side2 As Single) As Single Return Math.Sqrt((side1 ^ 2) + (side2 ^ 2)) End Function


How do I implement the function?


#9

Math.xaml (5.9 KB)


#10

Heheh thanks vvaidya. That xaml works but I was only using the hypotenuse function as an example.
How would this be implemented?

Private Function ListAppend(ByVal list As List(Of String), ByVal row As String) list.Add(row) End Function

Notice that I don’t want to return anything.


#11

Custom activites are still best for custom complex code (at least until InvokeCode activity is widely available).

But for simple void method calls, you can always use InvokeMethod activity.


#12

Does any of the training material demonstrate either how to build custom activities or how to implement a function in InvokeMethod?
I can’t find any comprehensive training examples.

Edit: What is the ETA on InvokeCode?


#13

Invoke Code is out in Community Edition


#14

So that is why I can’t find it the box.
I’m currently developing in a trial of the full version.
Rather than uninstalling my full version, is there a graceful way to have both versions installed on one machine?