Never used
_ANDALSO but I find it useful when I must test 2 conditions and the second can be false and it triggers a runtime error like for example out of range, so before the existence of _AndAlso I must write a first IF for the field of values good so that the second condition in the second IF doesn't trigger a runtime error.
Code: (Select All)
Dim a(1 To 7)
For c = 0 To 100
If c = 0 _AndAlso c Mod 24 = 0 Then Locate 1, 1 ' this will be executed one time
If c Mod 25 = 0 Then Sleep 1
Print c
row = CsrLin: column = Pos(0)
Locate 25, 1: Print " This doesn't disappear!";
Locate row, column
If c > 0 _AndAlso c < 8 Then a(c) = row ' this will be executed seven times
Next
Sleep 3
Cls
For c = 0 To 100
Select Case c
Case 0
Locate 1, 1
Case 1 To 7
a(c) = row
Case 25, 50, 75, 100
Sleep 1
End Select
Print c
row = CsrLin: column = Pos(0)
Locate 25, 1: Print " This doesn't disappear!";
Locate row, column
Next c
Sleep
System
But as Wiki explains it is useful for avoiding so many actions required in the following AND conditions when the first is false and the final result of conditions is false.
Select case let you set the values or the range of values to perform some actions. In this kind of decisions
about one variable: the values that activate the same action have been typed in the same CASE as a range or a list of values/conditions
Select Case wiki page so you can put the _andalso conditions into the same
CASE block without using _andalso keyword.