473,320 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Select Case Statement with Multiple Expressions

1
Does anyone know if it is possible and the syntax to test mutlitple expressions in a select case statement? This is the best I could come up with but it doesn't appear to be working

Example:

Expand|Select|Wrap|Line Numbers
  1. Select Case rng1.value And rng2.value
  2.  
  3. Case rng1.value = 1 & rng2.value = 2
  4.  
  5. 'code here
  6.  
  7. case rng1.value = 2 & rng.value = 2
  8.  
  9. 'code here
  10.  
  11. End Select
Jan 13 '10 #1
3 12591
MikeTheBike
639 Expert 512MB
Hi

You could try something like this
Expand|Select|Wrap|Line Numbers
  1. Sub TestSelect(ByVal Value1 As Integer, ByVal Value2 As Integer)
  2.  
  3.     Select Case True
  4.         Case (Value1 = 1 And Value2 = 2)
  5.             MsgBox "Value 1 = " & Value1 & " : Value 2 = " & Value2
  6.         Case (Value1 = 2 And Value2 = 2)
  7.             MsgBox "Value 1 = " & Value1 & " : Value 2 = " & Value2
  8.     End Select
  9.  
  10. End Sub
  11.  
  12. Sub Test()
  13.  
  14.     TestSelect 1, 2
  15.  
  16.     TestSelect 2, 2
  17.  
  18.     TestSelect 2, 1
  19.  
  20. End Sub
??


MTB
Jan 14 '10 #2
I have a quick question for MTB.

Do I need to use the Sub Test() with the TestSelect statements to make the above code work?

I have a similar situation where I need to evaluate two different fields on a form where the outcome of a third combobox depends on it.

I just don't understand the Sub Test part of your example.

Thanks
Jan 25 '10 #3
debasisdas
8,127 Expert 4TB
that part just calls TestSelect to show you as an example.
Jan 27 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to...
2
by: Omavlana | last post by:
Hi, I want to create a temporary table and store the logdetails from a.logdetail column. select a.logdetail , b.shmacno case when b.shmacno is null then select...
18
by: war_wheelan | last post by:
I am very new to Transact-SQL programming and don't have a programming background and was hoping that someone could point me in the right direction. I have a SELECT statement SELECT FIXID,...
21
by: Andy | last post by:
Can someone tell me if the following Switch...Case construct is valid? I'm wanting to check for multiple values in the Case statement without explicitly listing each values. So for example, will...
15
by: grunar | last post by:
After some thought on what I need in a Python ORM (multiple primary keys, complex joins, case statements etc.), and after having built these libraries for other un-named languages, I decided to...
10
by: Antanas | last post by:
The problem is that when AddID is used multiple times in the same select statement, it returns the same value in all places. How could I force function AddID to increment OBJECTID sequence? Here...
16
by: ME | last post by:
In C# the following code generates a compiler error ("A constant value is expected"): public void Test(string value) { switch (value) { case SimpleEnum.One.ToString(): MessageBox.Show("Test...
1
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case...
56
by: Adem | last post by:
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15) says under...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.