# Creating Functions/Subroutines inside Invoke Code

**URL:** <https://forum.uipath.com/t/creating-functions-subroutines-inside-invoke-code/55286>\
**Category:** Help\
**Tags:** system, activities\
**Created:** [August 2, 2018, 1:35pm UTC](https://forum.uipath.com/t/creating-functions-subroutines-inside-invoke-code/55286 "2018-08-02T13:35:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisL](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@chrisL](https://forum.uipath.com/u/chrisL)\
**Post date:** [August 2, 2018, 1:35pm UTC](https://forum.uipath.com/t/creating-functions-subroutines-inside-invoke-code/55286/1 "2018-08-02T13:35:31Z")

</div>

Hi,

I was wondering if it was possible to create custom functions or subroutines from within the Invoke Code activity?  
I know that custom functions and subroutines are possible using [VB.Net](http://VB.Net) but I seem to keep getting error while attempting to implement the way they use inside Invoke Code.  
The main errors are:  
“Statement cannot appear from within a method body”  
“End Sub must be preceded by a matching Sub”  
I’ve read the articles about how to use Invoke Code, but I can’t seem to find a way to do this.

Thanks,  
ChrisL

---

<div class="post-metadata">

**Author:** ![carmen](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/carmen/32/291789_2.png) [@carmen](https://forum.uipath.com/u/carmen)\
**Post date:** [August 2, 2018, 1:51pm UTC](https://forum.uipath.com/t/creating-functions-subroutines-inside-invoke-code/55286/2 "2018-08-02T13:51:30Z")

</div>

you should check this [Invoke code activity VB.Net example](https://forum.uipath.com/t/invoke-code-activity-vb-net-example/10903)

---

<div class="post-metadata">

**Author:** ![Masire](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/masire/32/206547_2.png) [@Masire](https://forum.uipath.com/u/Masire)\
**Post date:** [March 15, 2019, 4:31pm UTC](https://forum.uipath.com/t/creating-functions-subroutines-inside-invoke-code/55286/3 "2019-03-15T16:31:17Z")

</div>

Hi @chrisL,

I didn’t make multiples functions but I think it may be possible, take a look at this : [Invoke code activity Error - #5 by Masire](https://forum.uipath.com/t/invoke-code-activity-error/98031/5).

Regards,

@Masire

---

<div class="post-metadata">

**Author:** ![donghai](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/donghai/32/181872_2.png) [@donghai](https://forum.uipath.com/u/donghai)\
**Post date:** [February 3, 2020, 7:46am UTC](https://forum.uipath.com/t/creating-functions-subroutines-inside-invoke-code/55286/4 "2020-02-03T07:46:28Z")

</div>

Hi @chrisL  
I am face the same problem?  
Have you got the solution?  
Best Regards!

---

<div class="post-metadata">

**Author:** ![OpalSnow](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/opalsnow/32/140729_2.png) [@OpalSnow](https://forum.uipath.com/u/OpalSnow)\
**Post date:** [March 18, 2020, 11:35pm UTC](https://forum.uipath.com/t/creating-functions-subroutines-inside-invoke-code/55286/5 "2020-03-18T23:35:03Z")

</div>

Lambda seems to be the way to create custom functions/subroutines. See [Export log from Output panel to text file - #7 by OpalSnow](https://forum.uipath.com/t/export-log-from-output-panel-to-text-file/203833/7)

If this is not a viable option for you, you will have to create custom to get the job done. See [https://docs.uipath.com/activities/docs/creating-a-custom-activity](https://docs.uipath.com/activities/docs/creating-a-custom-activity) for more information.

---

<div class="post-metadata">

**Author:** ![JAltice](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jaltice/32/263532_2.png) [@JAltice](https://forum.uipath.com/u/JAltice)\
**Post date:** [January 30, 2022, 2:36am UTC](https://forum.uipath.com/t/creating-functions-subroutines-inside-invoke-code/55286/6 "2022-01-30T02:36:33Z")

</div>

I can make functions\methods inside an Invoke Code Activity when using C# but not with [VB.Net](http://VB.Net). Feel like there must be a way to do this for [VB.Net](http://VB.Net) without a custom activity. Anyone find another solution to this?
