When running debug at 4x slow speed, the invoke code no issue, but error when running at normal speed

Dim currentDate As String = DateTime.Now.ToString(“MM/dd/yyyy”)
Dim currentDateTime As DateTime = Convert.ToDateTime(currentDate)
Dim previousMonthDateTime As DateTime = currentDateTime.AddMonths(-1)
Dim firstDayOfPreviousMonth As New DateTime(previousMonthDateTime.Year, previousMonthDateTime.Month, 1)
Dim formattedDate As String = firstDayOfPreviousMonth.ToString(“MM/dd/yyyy”)

Above is the code runs well under debug 4x slow speed, but error occurred during normal speed.

This is the error.
Invoke Code: No compiled code to run
error BC30456: ‘SendKeys’ is not a member of ‘System.Windows.Forms’. At line 6

Please advise how to resolve this issue.

Hi @zzxken

Please you place a delay of 3 seconds before the invoke code & debug the same in the normal speed. Let us know if this works.

Hope this helps,
Best Regards.