Ui Path With Vb.NET Integration

studio

#1

Hi There.

I have a question for Ui Path Scripting.

I’m trying to make a Bot, to every day extract a base from our CMS application.

There are two fields that need to be filled: “Start” and “End” date.

This date need to be formated like this:
Every first day needs to be the first day in the month.
Every last day needs to be one day before today.

I’ve trying to make a lot of scrips and VB expresions, but i can’t integrate to Ui Path.

Can someone help me ?
Edit***

This is the error that i’m receiving
Main has thrown an exception

Source: Set Text ‘INPUT ctl09_cldDtStart…’

Message: Error HRESULT E_FAIL has been returned from a call to a COM component.

Exception Type: ElementOperationException

UiPath.Core.ElementOperationException: Error HRESULT E_FAIL has been returned from a call to a COM component. —> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
at UiPath.UiNodeClass.Set(String bstrAttr, Object vValue)
at UiPath.Core.UiElement.Set(String attribute, Object value)
— End of inner exception stack trace —
at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

My Script in VB.NET
If mes = “7” Then
If dia = “1” Then
Dim UltimoDia = DateTime.DaysInMonth(DateTime.Now.Year, 6)
Dim DataInicio = (“01/06/” + DateTime.Now.Year.ToString + " 00:00:00")
Dim DataFim = (UltimoDia + “/06/” + DateTime.Now.Year.ToString + " 23:59:59")
MsgBox(DataInicio.ToString)
Else
Dim PrimeiroDia = DateTime.Now.AddDays(-1).Day.ToString
Dim UltimoDia = DateTime.DaysInMonth(DateTime.Now.Year, 6)
Dim DataInicio = (“01/06/” + DateTime.Now.Year.ToString + " 00:00:00")
Dim DataFim = (PrimeiroDia + “/06/” + DateTime.Now.Year.ToString + " 23:59:59")
MsgBox(DataFim.ToString)
End If
Else
End If


#2

Try something like this:

firstDate = new DateTime(Today.Year, Today.Month, 1)
lastDate = DateTime.Now.AddDays(-1)

Here the XAML as a example: TestDate.xaml (7.5 KB)

Hope it helps :slight_smile:

Regards,


#3

But if today is the first day of the month, he has to collect the first and last day of last month.

Example:

If today was day 01/07/2018.

First day: 06/01/2018

Last day: 30/06/2018

Have something in your mind Lucas ?


#4

I was thinking in something about integrate an entire vb.net script, with ifs and else. It can be possible ?


#5

Check this out. This might help.