Issue in Invoke Code-Example

Hi ,

I am trying to implement invoke code activity with the below code.But I am facing issue like
“Module Member Declaration Expected”.Can someone please help with this?
image

code:

Imports System

Public Module Module1
Public Sub Main()
Dim a,b,c As Integer
a=5
b=10
c=a+b
Console.WriteLine(c)
End Sub
End Module

Thanks

1 Like

The same issue. Can someone help us, please?

Hi @lokesh
I think Invoke code does not support Class and Method define.
Works fine below

Dim a,b,c As Integer
a=5
b=10
c=a+b
Console.WriteLine( c)
InvokeCode

1 Like

Hi ,
I have written this code how can i make it work using invoke code activity please help

Imports System.IO

Module Module1

Private index1 As Integer = New StringHelper().GetIndexofSearchText("C:\Users\vivekver\Documents\UiPath\Nokia Automation\Configuration Manager Nokia 2nd\TEST.txt", "MRBTS-486203")
Private index2 As Integer = New StringHelper().GetIndexofSearchText("C:\Users\vivekver\Documents\UiPath\Nokia Automation\Configuration Manager Nokia 2nd\TEST.txt", "[TopologyNode: PLMN-PLMN/MRBTS-486215]")
Public index_Hotkey As Integer = New NoOfHotkeys().GetHotkey(index1, index2)

Public Class NoOfHotkeys
    Public Function GetHotkey(ByVal index1 As Int32, ByVal index2 As Int32)
        Dim index_Hotkey As Integer = index2 - index1
        Return index_Hotkey

    End Function

End Class
Public Class StringHelper

    Public Function GetIndexofSearchText(ByVal Filename As String, ByVal SearchText As String) As Integer
        Dim index As Integer = 0
        Dim lines As List(Of String) = File.ReadLines(Filename).ToList()
        For Each line In lines
            If line.Contains(SearchText) Then
                Return index
            End If

            index += 1
        Next

        Return index


    End Function
End Class

Sub Main()


End Sub

End Module

i want index_Hotkey as output to my uipath workflow.Please help!!

HI,

Yes invoke method doesn’t support class and sub.

Please check the below tutorial.

Thanks,
Karthik.

Hi @lokesh,
You can get the sample here.

Regards
Balamurugan