How to check for multiple things in a single if-statment

Hi!

Is there a way to check multiple things without doing a lot of if-statements?

I want to do like this, but in an easier way:

if System.DateTime.Now().Month.ToString(“MMM”) = "JAN" then blabla
else if System.DateTime.Now().Month.ToString(“MMM”) = "FEB" then blabla
else if System.DateTime.Now().Month.ToString(“MMM”) = "MAR" then blabla

Best thing would be if there exist anything like:

if System.DateTime.Now().Month.ToString(“MMM”) = {"JAN", "FEB", "MAR"} then {blabla1, blabla2, blabla3}

1 Like

Hi @jsylvan,

You can use switch case to achieve this one.

Refer below link

Regards,
Arivu :slight_smile:

2 Likes

@jsylvan as @arivu96 said, you can go for Switch case for replacing multiple if-else

1 Like

Thank you guys, it worked for the problem I described. But I have read it does not work with String.Contains(), is there any smarter way than doing tons of if-statements for that?

1 Like

Hi,

In that case, you may want to either to use a flowchart layout or even the “Invoke code” Activity, which will allow you to invoke VB.Net code directly.

Both approaches can be useful when you have a lot of decisions to handle, to keep the solution readable.

Cheers

1 Like