New topic: 

Select Case -- How to - or is this a bug?

<http://forums.realsoftware.com/viewtopic.php?t=43950>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        comcents          Post subject: Select Case -- How to - or is 
this a bug?Posted: Thu May 10, 2012 11:39 am                         
Joined: Mon Apr 11, 2011 12:42 am
Posts: 50                THis is RB 2011R4.3 PC 
Given:
Dim R1, R2, R3, R4, Use as Integer
R1  = 500000
R2  = 750000
R3  = 1000000
Use = 889050

  Select Case Use
  Case is <R1  // base level
  {some code}
  Case is >=R1, is <R2  //First Level Charges
  {some code}
  Case is >= R2, Is < R3  //Second Level Charges
   {some code}
  Case is >= R3, IS < R4
End select

What one would expect from this - (from the description and example in the User 
Guide) is that the first and second case would be bypassed - with the code for 
the 3rd case being executed. However - the SECOND case is executing - which 
leads me to believe that the multiple tests (separated by , (comma)) are being 
treated as OR rather than AND.  The example given in the User's Guide: 
Dim i as Integer = 75
Select Case i
Case 0, Is <=10,100
//case not selected
Case Is > 10, Is < 99
//case selected
End Select

When executed - the FIRST case is indeed selected - and it's code executed -IN 
SPITE of what the comments say (and no - the 2nd case does not also execute).  

Of course I re-did the code into an IF ELSEIF ENDIF  construct - which works as 
expected. 

So the questions:  Is the documentation wrong?  is there a way to write an 
inequality "AND" test?  

Sheesh.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to