Questions tagged [select-case]
164 questions
1
vote
2 answers
Can string functions be executed within a Select-Case statement?
In VB.NET, how can I achieve the following logic?
Select Case testString
Case Contains("ABC") : Debug.Print "ABC"
Case Contains("XYZ") : Debug.Print "XYZ"
Case Else : Debug.Print "Other"
End Select

CJ7
- 22,579
- 65
- 193
- 321
1
vote
1 answer
asp gridview visibility not triggered in select case
Within a vb asp.net webform I have a select case statement within a gridview databound procedure which is based on the values from a dropdown list as stored in a variable.
Protected Sub gvProgressGrid_DataBound(ByVal sender As Object, ByVal e As…

Matt
- 263
- 2
- 10
- 35
1
vote
1 answer
Select Case Function with Multiple Criteria is Not Looping
I am new to vba and my first time working with "Select Case". Briefly, I am trying to loop (number of rows will change from sheet to sheet) by finding the "cust_num" column header and go through each row, if the cust_num matches criteria on a…

Zachary Smith
- 59
- 2
- 4
- 14
1
vote
1 answer
conditional sum in sql, get correct sum from another table based on a condition in a field
I have a table (tbl1) like this, in which the sale amount for "store 3" is incorrect.
**date store sale**
Mar, 2013 store 1 100
Apr, 2013 store 1 80
Mar, 2013 store 2 70
Mar, 2013 store 3 125
Apr, 2013 store 3 …

saghar
- 67
- 1
- 3
- 10
1
vote
1 answer
SQL Subtracting values that were generated from existing columns using case function
I have created addition columns of numbers based on existing columns of text grades.
For example where a result is C there is a resulting column 14
Tar TarVal TA TAVal
A 20 A- 19
B 17 B+ 18
C 14 B+ 18
What…

Matt
- 263
- 2
- 10
- 35
1
vote
1 answer
VBA End if user selected cell is not within a series of named ranges
I am having trouble with a bit of Select Case. I have my program working with named ranges. I want it to End if the select case is not in a series of named ranges. Here is my code that is running correctly for when the user selects a valid…

user2044180
- 13
- 3
1
vote
2 answers
Select Case True in VB.NET
I have the following select case where I want to do some checks on what a string contains and call some functions for each case. But it seems that if multiple conditions are true it considers only the first condition. The problem is I have about 113…

user1570048
- 880
- 6
- 35
- 69
1
vote
2 answers
InStr not finding substring
I have the following code:
Columns("F:F").Select
For Each cell In Selection
Select Case cell
Case InStr(1, cell, ",") <> 0
MsgBox ("found")
Case IsEmpty(cell) Or Null
MsgBox ("empty")
Case Else
…

thedeepfield
- 6,138
- 25
- 72
- 107
1
vote
4 answers
Is there a better way to write the following VB6 snippet?
I work at $COMPANY and I'm helping maintain $LEGACY_APPLICATION. It's written in visual basic 6.
I was faced with doing an unpleasantly elaborate nested if statement due to the lack of VB6's ability to perform short circuit evaluations in if…

Wug
- 12,956
- 4
- 34
- 54
1
vote
1 answer
If-then / Select Case for date range defined in cell reference
I apologize for the newb question but have not found a solution online. I am trying to do a simple if-then statement on date ranges in VBA. My code (not working) thus far:
LR = 52
Set rngData = Range("D2:D" & LR)
…

baha-kev
- 3,029
- 9
- 33
- 31
0
votes
0 answers
How update the value in SubForm if is duplicate in access
In access I have Form name FB (table name = FB) and SubForm name FBB ( table =FBB) (relationship one to many)
I use
( currentdb.execute "insert into FBB (FBID, ProductName, Quantity) "& _value (" & me.FBID &",'" & me.ProductName &"','" & me.Quantity…
0
votes
3 answers
MySQL create function for range of values with equivalent numbers
What is wrong with this function. Here is my expected output is
1 = 10
2 to 3 = 7
4 to 10 = 5
11 to 30 = 2
31 to 100 = 1
DELIMITER $$
DROP FUNCTION IF EXISTS `computeScore`$$
CREATE DEFINER=`root`@`localhost` FUNCTION `computeScore`(`POS`…

Aivan Monceller
- 4,636
- 10
- 42
- 69
0
votes
1 answer
Incorrect Syntax - Microsoft Access VBA data filter - Select Case
I think this should be an easy one but I am struggling to find the correct way to write this and am running out of time to complete.
I have an Access form that uses multiple drop down boxes to filter the records to display in the form. I am…

JBeets
- 23
- 7
0
votes
3 answers
Reducing Cyclomatic Complexity in a select
Good day coding godz,
I am trying to clean up some code and was wondering how to reduce the Cylcomatic Complexity on a method I have created. This method is used during an Import of a CSV file. One of the fields in the CSV file is a license type…

Gary
- 21
- 6
0
votes
3 answers
Convert inch to mm using macro select Case in Word VBA
Trying to get this macro to work in Word VBA. Any help to fix this would be greatly appreciated.
Sub ConvertToMM()
Dim wrdFind As Find
Dim wrdRng As Range
Dim wrdDoc As Document
Dim inch_in As Integer
Dim mm_out As Variant
Set wrdDoc =…

Mapleleaf
- 1
- 2