Android Question [SOLVED] Help with an IF clause

techknight

Well-Known Member
Licensed User
Longtime User
Now, I suppose I am getting more stupid as I age, but I must be missing the obvious.

This works if its either one of the string matches, which is a desired operation:
B4X:
If VarD = "GqrNrmcZyTvqG67B" Or VarD = "E4YhdpBsQ88jWR6p" Then


However, I am trying to do a return if VarD does not contain either one of those, like this:
B4X:
If VarD <> "GqrNrmcZyTvqG67B" Or VarD <> "E4YhdpBsQ88jWR6p" Then Return

But, it doesnt work. it returns regardless if VarD has either one of the strings.

I want it to work like this: If VarD doesn't contain either of those strings exactly as they are, then return.

Thoughts?

?
 

drgottjr

Expert
Licensed User
Longtime User
and, not or.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
??
VarD.Contains("GqrNrmcZyTvqG67B") Or VarD.Contains("E4YhdpBsQ88jWR6p")

1611781310228.png
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Use of Not
Your code works great, but I wanted to be a little fancy like Erel would do sometimes:
B4X:
Log(oparra("GqrNrmcZyTvqG67B"))
B4X:
Sub oparra( Vard As String) As Boolean
    Return Not(Vard.Contains("GqrNrmcZyTvqG67B".trim) Or Vard.Contains("E4YhdpBsQ88jWR6p".trim))
End Sub
or this:
B4X:
Sub oparra( Vard As String) As Boolean
    Return Not(Vard = "GqrNrmcZyTvqG67B" Or Vard = "E4YhdpBsQ88jWR6p")
End Sub
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Your code works great, but I wanted to be a little fancy like Erel would do sometimes:
B4X:
Log(oparra("GqrNrmcZyTvqG67B"))
B4X:
Sub oparra( Vard As String) As Boolean
    Return Not(Vard.Contains("GqrNrmcZyTvqG67B".trim) Or Vard.Contains("E4YhdpBsQ88jWR6p".trim))
End Sub
or this:
B4X:
Sub oparra( Vard As String) As Boolean
    Return Not(Vard = "GqrNrmcZyTvqG67B" Or Vard = "E4YhdpBsQ88jWR6p")
End Sub
I thought about it but was guided by the code of the post.

an old saying:
Although all roads lead to Rome.

;););)
 
Upvote 0
Top