# Is there another way for use if in if?

Hello,

I want to question about my code.

Now I use if and if inside again as below.

if condition in_int_count = 0
if condition in_int_count = 0 and in_boo_chk = true

else

Is have another way to solve it?

Use the below condition:

``````If in_int_count = 0 AndAlso in_boo_chk = True
Then
Else
Other code logic here
End If
``````

As per your If statements you check `condition in_int_count = 0` in both the If. Rather than that use single If and check if the boolean variable is True and count = 0.

Regards

It seems like if count=0 and chk= true then you need to perform certain actions.
I feel that no need of using outer if.Check with the below one

``````If condition: (in_int_count = 0 AND in_boo_chk = True)
Then:
[Actions if both conditions are true]
Else:
[Actions if either condition is false]

``````

@vrdabberu my case as below.

1. in_int_count = 0 AndAlso in_boo_chk = True
2. in_int_count = 0 AndAlso in_boo_chk = False
3. in_int_count <> 0

Then use Else If activity to check the conditions.

``````If in_int_count = 0 AndAlso in_boo_chk = True
Then
Your code logic for the first condition (when in_int_count is 0 and in_boo_chk is True)

ElseIf in_int_count = 0 AndAlso in_boo_chk = False
Then
Your code logic for the second condition (when in_int_count is 0 and in_boo_chk is False)

ElseIf in_int_count <> 0
Then
Your code logic for the third condition (when in_int_count is not 0)

End If
``````

Regards

1 Like
1 Like

Hi,

Since in_int_count = 0 is common, you can use it outside and then inside check in_boo_chk = True and else will be false so the logic is as follows

if in_int_count = 0
if in_boo_chk = True
else “for false”
else “for not zero”

regards.

1 Like

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