hello,

anyone can help me , how to calculate leap year through while loop in UiPath.i am unable to slove

hello,

anyone can help me , how to calculate leap year through while loop in UiPath.i am unable to slove

Hello @Madhu_Maurya

Dim year As Integer = 0

Dim isLeapYear As Boolean = False

’ User input: Prompt the user to enter a year

year = CInt(InputBox(“Enter a year:”))

’ Check if the entered year is a leap year

While year > 0

If (year Mod 4 = 0 And year Mod 100 <> 0) Or (year Mod 400 = 0) Then

isLeapYear = True

End If

year -= 1

End While

’ Display the result

If isLeapYear Then

MsgBox(“The entered year is a leap year.”)

Else

MsgBox(“The entered year is not a leap year.”)

End If

Thanks & Cheers!!!

If activity:

Condition: (year Mod 400 = 0) Or ((year Mod 100 <> 0) And (year Mod 4 = 0))

Then:

Assign activity:

Variable: isLeapYear (Boolean)

Value: True

Else:

Assign activity:

Variable: isLeapYear (Boolean)

Value: False

Hi,

If you need to check the specific year is leap year or not, the following expression will work.

```
DateTime.IsLeapYear(2023)
```

If you need to check whether this year is leap year, the following will work.

```
DateTime.IsLeapYear(Now.Year)
```

If you need to get leap year in the nearest this year, the following will work.

```
Enumerable.Range(Now.Year,8).Where(Function(y) DateTime.IsLeapYear(y)).First()
```

Regards,

actually i want to get output using while loop

Assign: year = Input Dialog or other input method

Assign: isLeapYear = False

While (year <= CurrentYear)

Assign: isLeapYear = (year Mod 4 = 0) And ((year Mod 100 <> 0) Or (year Mod 400 = 0))

Assign: year = year + 1

End While

Message Box: "The year is a leap year: " + isLeapYear.ToString

Hope it helps!!

hey can you share zip file.

Hey @Madhu_Maurya ,

I have created your requirements

Below is the zip file

While loop.xaml (7.5 KB)

Hope it helps you out!

why you used two times input dialog box can you explain.

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