Solved

Select case and OR statement

Posted on 2002-03-23
6
139 Views
Last Modified: 2010-05-02
Hi everyone,

while stepping through code in excel i saw this

-somevalue has the value of 36.8
-in the debugger
-?Range("J" & iRow - 4) gave 0
-?Range("L" & iRow - 4) gave 36.8

so you would expect this statement to be true and teh code go into dosomething

select case somevalue
  case is = Range("J" & iRow - 4) Or Range("L" & iRow - 4)
    dosomething
  '......more comes here
end select

-the following worked as expected

select case somevalue
  case is = Range("J" & iRow - 4)
    dosomething
  case is = Range("L" & iRow - 4)
  '......more comes here
end select

-in the debugger the statement Range("J" & iRow - 4) Or Range("L" & iRow - 4) gave 37!

am i missing something here, it's not a real problem only a question maybe i'm doing something wrong in using the OR statement in the case select

:O)Bruintje
0
Comment
Question by:bruintje
  • 2
  • 2
  • 2
6 Comments
 
LVL 44

Author Comment

by:bruintje
ID: 6891405
replaced the line with

Case Is = Range("J" & iRow - 4): Case Is = Range("L" & iRow - 4)

which worked ok but i still want to know about the case select and the OR
0
 
LVL 3

Accepted Solution

by:
Bahnass earned 51 total points
ID: 6891431
I think
case Range("J" & iRow - 4) , Range("L" & iRow - 4)


in VB we say

SELECT CASE VARA
    CASE A,B
        ' means vara = a or vara=b
        dosomething
    case c

    case is > C

    Case ELSE

end select
   
0
 
LVL 12

Expert Comment

by:roverm
ID: 6891432
I think that the .Value tries to read an integer value.
Try reading it as a string ?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 44

Author Comment

by:bruintje
ID: 6891439
that did it!

thanks a lot learned something new because in VB i did the same thing Case Is = but Case X,Y seems logical

:O)Bruintje
0
 
LVL 3

Expert Comment

by:Bahnass
ID: 6891582
thanks 4 points & Grade
0
 
LVL 12

Expert Comment

by:roverm
ID: 6892002
LOL - Overread that one..... ;-)
Great catch Bahnass!

D'Mzzl!
RoverM
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question