# Invoke Code에서 Lambda Expression 사용하기

**URL:** <https://forum.uipath.com/t/invoke-code-lambda-expression/211017>\
**Category:** Korea RPA 개발자를 위한 공간\
**Created:** [April 11, 2020, 10:47am UTC](https://forum.uipath.com/t/invoke-code-lambda-expression/211017 "2020-04-11T10:47:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Minoh\_Kang](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/minoh_kang/32/59549_2.png) [@Minoh\_Kang](https://forum.uipath.com/u/Minoh_Kang)\
**Post date:** [April 11, 2020, 10:47am UTC](https://forum.uipath.com/t/invoke-code-lambda-expression/211017/1 "2020-04-11T10:47:59Z")

</div>

액티비티를 조합하여 워크플로우로 구현하자면 양이 많아지고 복잡한 타스크를 [VB.Net](http://VB.Net) 코드로 구현하면 훨씬 간단하게 끝낼 수 있는 경우가 많이 있습니다. 적절하게 코드를 사용하면 워크플로우가 지나치게 커지고 복잡해지는 것을 방지할 수 있고, 가독성도 좋아집니다.

Invoke Code 액티비티로 [VB.Net](http://VB.Net) 코드를 작성할 때에는 Function이나 Subroutine은 사용할 수 없습니다. 코드 안에 정의하면 아래와 같은 에러가 발생합니다. 그보다 상위의 컨테이너인 Module도 마찬가지입니다.

 ![image](https://global.discourse-cdn.com/uipath/original/3X/3/f/3f9ae0e9947c8b130cf94833d5ad3f16a75aa7c2.png)

코드에서 Function이나 Subroutine이 꼭 필요하다면 lambda expression을 사용하면 됩니다. 아래의 예에서는 lambda expression으로 "AddTwoNumbers"라는 Function을 구현하고 있습니다. "Func(Of Integer, Integer, Integer)"의 세 Integer 중 앞의 두 개는 이 함수가 취하는 인수이고, 마지막 Integer는 이 함수가 반환하는 타입입니다.

 ![image](https://global.discourse-cdn.com/uipath/original/3X/f/9/f9ad5c873de6822a369379213465f1fcc5c9199c.png)

Lambda expression의 syntax는 표준 Function이나 Subroutine과는 조금 다릅니다. 구체적인 내용은 아래의 마이크로소프트 문서를 참고하시기 바랍니다.

> **[Lambda Expressions - Visual Basic](https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/lambda-expressions)**
>
> Learn more about: Lambda Expressions (Visual Basic)

---

<div class="post-metadata">

**Author:** ![Minoh\_Kang](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/minoh_kang/32/59549_2.png) [@Minoh\_Kang](https://forum.uipath.com/u/Minoh_Kang)\
**Post date:** [April 11, 2020, 11:02am UTC](https://forum.uipath.com/t/invoke-code-lambda-expression/211017/2 "2020-04-11T11:02:11Z")

</div>

동일한 내용이 작년에 이미 포스팅 되었었네요…

> [@Invoke code activity Error](https://forum.uipath.com/t/invoke-code-activity-error/98031/5):
>
> 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](https://www.dotnetperls.com/lambda-vbnet)). So, to make your FindMax function in UiPath I followed the following steps: Create the variables in UiPath Add the Invoke code activity in a Sequence and edit arguments to create a “bridge” with previously created variables Create the Lambda Expression doing the job I want
