Invoke code activity Error


I want to create function using with code in invoke code activity.
But its give error, please any one help me.

Module myfunctions
Function FindMax(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
’ local variable declaration */
Dim result As Integer

  If (num1 > num2) Then
     result = num1
     result = num2
  End If
  FindMax = result

End Function
Sub Main()
Dim a As Integer = 100
Dim b As Integer = 200
Dim res As Integer

  res = FindMax(a, b)
  Console.WriteLine("Max value is :", res)

End Sub
End Module

The UiPath documentation is quite brief in InvokeCode activity description :frowning:
But I suppose you could not declare Module inside InvokeCode, maybe not even Function, just plain .NET code


See more here Invoke code activity VB.Net example

As pointed out by others, there’s no need for a module or function statement, and the Invoke Code activity supports neither. However, what you’re trying to do is already part of .NET - no need to reinvent the wheel:


Hello @malam9384,

Hope you’re doing well. I think I had the same problem as yours and this is how I figured it out : using Lambda Expressions (please see example here VB.NET Lambda Expressions - Dot Net Perls).

So, to make your FindMax function in UiPath I followed the following steps:

  1. Create the variables in UiPath
  2. Add the Invoke code activity in a Sequence and edit arguments to create a “bridge” with previously created variables
  3. Create the Lambda Expression doing the job I want
  4. That’s all folks!

You’ll find attached the working XAML file for this example FindMax With Invoke Code.xaml (5.7 KB).



Hi @Masire
I am faceing the problem that use System.Drawing.Point type in the invoke code activity,but It will be occur errors , do you have solution?
Like the below post

I found the docs right now!

But there is no System.Drawing.Point.My God
How can I do it?