Questions tagged [select-case]
158 questions
95
votes
13 answers
javascript: using a condition in switch case
Sorry for that dumb question.
How can I use a condition for a case in the javascript switch-case language element?
Like in the example below, a case should match when the variable liCount is <=5 and >0; however, my code does not work:
switch…
![](../../users/profiles/668550.webp)
haemse
- 3,079
- 4
- 25
- 38
46
votes
3 answers
What is the equivalent of Select Case in Access SQL?
I have a query which includes fields named openingbalance and commissions. I would like to compute values for commissions based on openingbalance, similar to this Select Case block in Access VBA:
Select Case OpeningBalance
Case 0 To 5000
…
![](../../users/profiles/2072513.webp)
Kelly K.
- 477
- 1
- 5
- 9
42
votes
5 answers
Select Case on an object's type in VB.NET
I'm not sure if this valid C#, but hopefully you get the idea. :)
switch (msg.GetType()) {
case ClassA:
// blah
case ClassB:
// blah 2
case ClassC:
// blah 3
}
How would I switch on an object's type but using…
![](../../users/profiles/30323.webp)
mcjabberz
- 9,498
- 10
- 34
- 36
24
votes
1 answer
Can you use .Contains(string) with a Select Case Statement?
Is there anyway I can build a Select statement that uses the Contains function? Like this:
Select commentStr
Case commentStr.Contains("10")
Case commentStr.Contains("15")
![](../../users/profiles/200626.webp)
Lou
- 888
- 3
- 15
- 28
23
votes
2 answers
Why should I use exit select?
Here are a couple of questions I gathered regarding exit select...
Is there any reason for using exit select in VB.NET?
Does the reason have anything to do with performance?
Is the exit select equal to break;?
Example 1
Select case Name
case…
![](../../users/profiles/59314.webp)
OrElse
- 8,657
- 36
- 127
- 234
13
votes
3 answers
Multiple select cases in VB.NET
I have tried the below:
Select Case Combo1.SelectedItem Or Combo2.SelectedItem
But I get the error:
Conversion from String "string here" to type 'Long' is not valid
Is it possible to have multiple select cases?
![](../../users/profiles/1295053.webp)
user1295053
- 263
- 1
- 5
- 17
12
votes
2 answers
Excel VBA: Select Case if ActiveCell like "*string*"
I'm working on a macro that takes the current value of the ActiveCell and changes that value based on a select case.
However, I am unable to determine if the ActiveCell contains a wild card string. I am not sure if my syntax is correct. How can I…
![](../../users/profiles/500401.webp)
thedeepfield
- 5,814
- 23
- 68
- 104
8
votes
6 answers
Converting DayOfWeek enum to a string repesenting the day
I was wondering if there was a way to directly convert the integer DayOfWeek returns into a string representing the day like Monday, Tuesday etc.
Sample code:
MessageBox.Show(Date.Today.DayOfWeek)
This will return 6 (as of today). Is there a way to…
![](../../users/profiles/261314.webp)
James
- 119
- 2
- 3
- 6
8
votes
3 answers
How can you use COUNT() in a comparison in a SELECT CASE clause in Sql Server?
Let's say you want do something along the following lines:
SELECT CASE
WHEN (SELECT COUNT(id) FROM table WHERE column2 = 4) > 0
THEN 1 ELSE 0 END
Basically just return 1 when there's one or more rows in the table, 0 otherwise. There has…
![](../../users/profiles/279112.webp)
Panzercrisis
- 4,214
- 6
- 36
- 75
7
votes
2 answers
VB.net Select Case Statement with Beginswith
Is there a way to use the Select Case statment in VB.net for beginswith? Or do i have to use a long elseif? Example:
If text.StartsWith("/go") then
elseif test.StartsWith("/stop")
elseif test.StartsWith("/continue")
End If
But instead something…
![](../../users/profiles/270483.webp)
James T
- 3,141
- 8
- 39
- 67
7
votes
5 answers
C# Switches vs. VB Case Statements
I recently switched from VB to C#. One thing that I noticed was that in C#, I have problems using comparisons as part of the case. I am not sure how to explain it in words, so here is an example of what I am trying to do.
In VB, my code looks like…
![](../../users/profiles/2763890.webp)
user2763890
- 75
- 2
- 6
6
votes
2 answers
Select Case Not Or
I'm looking to carry out a Select Case with just one case - where the case is not equal to "P", "Ev" or "Af".
This is what I have so far.
Select Case Range("my_range").Offset(0, column_offset).Value
Case Not "P", "Ev", "Af"
'my code
End…
![](../../users/profiles/3493560.webp)
tom_j_uk
- 137
- 1
- 2
- 7
6
votes
3 answers
How to sense parameters with Case
I'm trying to create a series of commands that can take parameters. To pick up each separate command I am using Select Case The problem with this is I can't sense the 'parameters' (the second part of the string) if I use Case Else. If I don't use…
![](../../users/profiles/2854842.webp)
08robertsj
- 264
- 3
- 5
- 17
6
votes
6 answers
Ending a Case Early
So I have something like the following in Vb6;
Select case Case
case "Case0"
...
case "Case1"
if Condition Then
Exit Select
End If
*Perform action*
case "Case2"
...
End Select
But for some reason my Exit Select throws the error…
![](../../users/profiles/1365650.webp)
windowsgm
- 1,504
- 4
- 21
- 50
5
votes
3 answers
Select Case With Conditions ( Classic ASP)
<%
i=2
Select Case i
Case 1,2,3,4,5,7,8,9,10
response.write("Grade A")
Case 11,12,13,14,15,16,17,18,19,20
response.write("Grade B")
Case 21,22,23,24,25,26,27,28,29,30
response.write("Grade C")
Case…
![](../../users/profiles/7511891.webp)
Skullcandy
- 77
- 1
- 1
- 4