'IF' with 'AND'/'OR' ...
Posted on 1998-12-16
This is VERY ODD...
pos = instr(1,"HELLO WORLD","XX")
'pos will = 0 since "XX" wont be found in it
if pos > 0 or (pos > 0 and mid("HELLO WORLD",pos)="WORLD") then
The if statement above is ILLEGAL in VB because eventhough i have a "pos > 0" for the second condition in the "if" statement it still processes the entire condition making the "mid" function invalid since pos cannot be < 1:
ILLEGAL: mid("HELLO WORLD",0)="WORLD")
This is correct but since i had the "pos > 0" at the beginning of the 2nd condtion it should not have allowed the rest of the condition to be processed thus preventing the mid() function from returning an error. I have NEVER seen any other programming language do this before. It is like vb is checking the validity of the ENTIRE line before it begins to process it. Really ODD! Is there a way around this, preferably keeping my entire conditions all in one "if" statement?