Android Question question about if and NOT

tufanv

Expert
Licensed User
Longtime User
hi

I have the code :

B4X:
If days>48 Then
lbl1.text = "ok"
end if
I want to add something to this code : I want to check if days>48 but not 168.

To describe shortly if days = 168 i dont want the above code to execute. so i tried to use

if days>48 and not days=168 then ...
but it didnt work .

How can i do that
TY
 

JoeR

Member
Licensed User
Longtime User
I am not a great expert, so I hope somebody else will do a double-check, but I think the following will work.
B4X:
If days>48 AND days<>168 Then
lbl1.text = "ok"
End If
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
hi

I have the code :

B4X:
If days>48 Then
lbl1.text = "ok"
end if
I want to add something to this code : I want to check if days>48 but not 168.

To describe shortly if days = 168 i dont want the above code to execute. so i tried to use

if days>48 and not days=168 then ...
but it didnt work .

How can i do that
TY
You can use "If days>48 And days<>168 Then"

Regards,
RandomCoder
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
I would have written this earlier but wanted to test it first, you can also use the following code which makes use of the Not keyword...
B4X:
If days>48 AND Not(days=168) Then
I think that the reason it didn't work for you previously is that you need to contain the boolean logic in brackets after the Not keyword.

Kind regards,
RandomCoder
 
Upvote 0
Top