mardi 13 juin 2017

How to use "And" and "Or" keywords together in a same "If" statement

I'm trying to use And and Orkeywords on a single If statement in my VB Script, which I use with VLC Media Player to stream using command line. I tried it like:

If (CurrentEP >= 2) And (CStr(TSNStr) = CStr(PTSNStr)) And (((CInt(TSSEPStr) - CInt(PTSSEPStr)) <= 5) Or ((CInt(TSSEPStr) - CInt(PTSSEPStr)) >= -5)) Then

I tried putting parentheses for the whole If statement, but it did nothing.

If ((CurrentEP >= 2) And (CStr(TSNStr) = CStr(PTSNStr)) And (((CInt(TSSEPStr) - CInt(PTSSEPStr)) <= 5) Or ((CInt(TSSEPStr) - CInt(PTSSEPStr)) >= -5))) Then

When I execute my script, only below two conditions seems to work.

1.If ((CurrentEP >= 2) Then '<< FIRST CONDITION

2.If (CStr(TSNStr) = CStr(PTSNStr)) Then '<< SECOND CONDITION

The third condition

(((CInt(TSSEPStr) - CInt(PTSSEPStr)) <= 5) Or ((CInt(TSSEPStr) - CInt(PTSSEPStr)) >= -5)))

always evaluates to false, which should check if difference of TSSEPStr and PTSSEPStr is either less than / equal to 5 or greater than / equal to -5.

I want to know if is it possible to use an Or keyword in a statement that is also used with multiple other And keywords in VB Script.

Aucun commentaire:

Enregistrer un commentaire