Select Case where Case has more than one test

Using LO 5.4 for Win_64

I am unable to return TRUE on either cae in the following Select Case…
To find 10% I need to know that CASE is both Equal to or greater than progCount AND less-than ( progCount * 2) and so on…

counter = 386

progCount = (counter / 10)

for i = 1 to counter step 8

Select Case i		
		case >=(progCount) & < (progCount * 2)
		msgBox "10%"
		case  >=(progCount * 2) & < (progCount * 3)
		msgBox "20%"
		REM ...
	End Select

next i

Hello @digifoss,

i don’t think the expression after “case” can start with an operator.
Please try with “To” instead:

Select Case i       
    case (progCount) To (progCount * 2)
        msgBox "10%"
    case (progCount * 2) To (progCount * 3)
        msgBox "20%"
    REM ...
End Select

HTH, lib

Documentation is at Select...Case Statement [Runtime] - LibreOffice Help.


The operator & is not a logical conjunction. It denotes for concatenation of strings. The Select Case construct uses the comma in place of the logical disjunction (OR). There is no substitute for AND as far as I know. My suggestion:

Select Case Int(i / progCount)  
  Case 1 : msgBox "10%"
  Case 2 : msgBox "20%"
End Select

Credits to @librebel , of course.
(And the colons were missing. The above linked wiki page seems to be incorrect. Tell me, please if it’s otherwise. See also my comment.)

I see. The example given in the above linked wiki page is working.
I now wonder if this is just a case of permissive behaviour of the interpreter or actually specified BASIC syntax.
It’s a mess if we are subject to the modern ways where you have to learn from examples instead of mandatory specifications. Who selects the examples and by what means does he (f/m) make sure they are correct?
See also!

The colon is a usual Basic syntax to allow two statements on one line. If put on different lines, no colons required.

Thanks for both suggestions guys. I saw Jim K answer last night and that worked great, so I changed it using TO and removed the operators.

@mikekaganski: I know about the colon as statement delimiter. However the BASIC guide I linked to (anchor: “See also!”) puts it as if the colon also separates the Case part from the statement part of a case. The missing clarity in such things was what I critisized. An additional empty statement created by a spare colon should not be a problem…