How can I convert an object of Type 'Object' to an array of String in UiPath

studio

#1

I am getting error while trying to convert an object of type Object to String Array using DirectCast Method. Please help


#2

what is your object ?


#3

thanks I got the Answer.

the Object was of type Object Class.


#4

Hi, I could use some help with a similar issue. The output from an excel macro is an object type in UiPath. The excel macro returns a Date() array. I need to work with this MacroOutput object. I have tried Directcast and Convert.changetype but neither will compile in UiPath. I get the Option Strict On error trying to make an implicit conversion. I think I need to find a fix to the error in the vb code rather than try to turn off Option Strict.

Here is what I’ve tried:

MacroOutput (astype Object)
NewDates (astype DateTime())

NewDates = convert.ChangeType(MacroOutput,NewDates.GetType)

Another option: I can see the MacroOutput array in the locals window during execution and it has the proper dates I need to work with, so I know it is valid. How do I assign a variable to the MacroOutput object in UiPath? The assign container will not accept the simple NewDate(0) = MacroOutput(0) due to the Strict On option

Thanks for your thoughts.


#5

In my search, I found the answer…I overlooked the VB CType function and that did the trick. For others to learn if reading this post…in an assign container:

NewDates = ctype(MacroOutput, Date())


#6

Both CType and DirectCast will work.


#7

Hi, thanks, that makes perfect sense that both will work. I think when I first tried DirectCast, my syntax was wrong.