QB64 Phoenix Edition
Using And with two InStr calls - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Using And with two InStr calls (/showthread.php?tid=3637)



Using And with two InStr calls - CMR - 04-25-2025

Anybody know how to make this work?  Maybe a 'Not InStr Xor InStr'?   My problem is InStr doesn't return true or false, but the position of the substring inside the string.  Maybe I need to rethink the whole structure.  I want to be able to default to -sh (run CreateSheet) if no option is given.

Code: (Select All)

If InStr(LCase$(opt$), "-sh") And InStr(LCase$(opt$), "-st") Then
    Print "-sh -st"
    CreateSheet sheet&, f_names$(), n_count&, bpp&
    CreateStrip strip&, f_names$(), n_count&, bpp&
ElseIf InStr(LCase$(opt$), "-st") Then
    Print "-st"
    CreateStrip strip&, f_names$(), n_count&, bpp&
Else
    CreateSheet sheet&, f_names$(), n_count&, bpp&
End If



RE: Using And with two InStr calls - Petr - 04-25-2025

Try add > 0
 if instr.... > 0 and instr... > 0 then...


RE: Using And with two InStr calls - SMcNeill - 04-25-2025

_AndAlso for logic decisions and not binary comparisons.

If instr... _AndAlso instr.... then


RE: Using And with two InStr calls - CMR - 04-25-2025

Thank you both.  I knew the answer was probably simple.