Vb. Net code arguments doubt in uipath

I am having vb. Net code I am invoked that code in UiPath using invoke code.

In my inside code I have initialized the list of string variable. Variable name is = listvariable.

After some operations I have added some values to the above declared list.

I need to get the list variable for outside code how to get this using argument panel

Hi @BHUVAN

Can you share what is the code you have written.

Regards

Imports System.IO
Imports System.Collections.Generic

Dim valuesOnlyInFile1 As New List(Of String)

Dim file1 As String = “file1.txt”
Dim file2 As String = “file2.txt”

Dim linesFile1 As List(Of String) = File.ReadAllLines(file1).ToList()
Dim linesFile2 As List(Of String) = File.ReadAllLines(file2).ToList()

For Each line As String In linesFile1
If Not linesFile2.Contains(line) Then
valuesOnlyInFile1.Add(line)
End If
Next

’ I need this - values Only File1 value for out
valuesOnlyInFile1

@BHUVAN

In invoke code click on import arguments

List data I need to declare which type could you mention it please

Hi @BHUVAN

Try this code:

Imports System.IO
Imports System.Collections.Generic

Dim valuesOnlyInFile1 As New List(Of String)

Dim file1 As String = "file1.txt"
Dim file2 As String = "file2.txt"

Dim linesFile1 As List(Of String) = File.ReadAllLines(file1).ToList()
Dim linesFile2 As List(Of String) = File.ReadAllLines(file2).ToList()

For Each line As String In linesFile1
    If Not linesFile2.Contains(line) Then
        valuesOnlyInFile1.Add(line)
    End If
Next

' Convert List(Of String) to a single string with values separated by newline
valuesOnlyFile1String = String.Join(Environment.NewLine, valuesOnlyInFile1)

valuesOnlyFile1String, give this variable as Out Argument in Invoked Arguments and create a variable in the process. After that you can use Log Message or Message Box to print that vairable.

or simply use this:

Imports System.IO
Imports System.Collections.Generic

Dim valuesOnlyInFile1 As New List(Of String)

Dim file1 As String = "file1.txt"
Dim file2 As String = "file2.txt"

Dim linesFile1 As List(Of String) = File.ReadAllLines(file1).ToList()
Dim linesFile2 As List(Of String) = File.ReadAllLines(file2).ToList()

For Each line As String In linesFile1
    If Not linesFile2.Contains(line) Then
        valuesOnlyInFile1.Add(line)
    End If
Next

' Join the elements of valuesOnlyInFile1 into a single string separated by a newline
Dim valuesOnlyInFile1String As String = String.Join(Environment.NewLine, valuesOnlyInFile1)

' Output the string containing values from valuesOnlyInFile1
Console.WriteLine(valuesOnlyInFile1String)

Hope it helps!!

@BHUVAN

check the thread

@BHUVAN

image

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.