Questions tagged [select-case]

164 questions
0
votes
1 answer

Group BY in SELECT CASE SQL

hi i have a query that return YES or NOT for each user now in result i want to add StudentId for showing better result how i can do this? WITH Prev AS ( SELECT StudentId, ISNULL(SUM(Score),0) As HighScoreUser FROM (SELECT StudentId, Score FROM…
user7647348
0
votes
2 answers

Check if string is in array or not including wildcards with Excel VBA

I found this function to identify whether a string is in a given array, however it does not seem to be able to handle wildcards (or atleast not the way i do it). Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean IsInArray =…
0
votes
2 answers

Declaring a case list to be used in more than one place

I have the following code in my page which works fine although the number of cases is much much bigger. I need to use exactly the same list of cases in other selects but I don't want to have exactly the same code duplicate all over the place. I…
Tom
  • 12,776
  • 48
  • 145
  • 240
0
votes
2 answers

Using multiple conditions within a single case statement

I have 5 numbers and want to test if 3 of them are identical so I wrote this: Select Case Reel1Num Case (Reel2Num And Reel3Num) Or (Reel2Num And Reel4Num) Or (Reel2Num And Reel5Num) Or (Reel3Num And Reel4Num) Or (Reel3Num And Reel5Num) Or (Reel4Num…
0
votes
0 answers

CASE SELECT is limiting returning rows

I've a scenario when a SELECT CASE statement is limiting the number of rows returned. Whilst I'm not a professional DB, I get by with some reasonable SQL and I didn't think that a SELECT CASE would actually limit the results?, just perform the THEN…
0
votes
3 answers

How to get second match from string on Visual Basic?

I'm doing Hangman Game in Visual Basic. I'm looking for typing a letter in a TextBox and clicking a button to check out. If that letter is in String, it will return position but when the word has two matches... How could I do it? Next code only…
Mrquestion
  • 771
  • 1
  • 6
  • 16
0
votes
3 answers

SQL Server: SELECT 4 non-empty columns and concatenate them

Let's say i have the following setup MailsTable Mail1 Varchar(40) Mail2 Varchar(40) Mail3 Varchar(40) Mail4 Varchar(40) Now i'm building a Query that shall include rows that have at least 1 Mail that isn't empty (Mail1 or Mail2...etc). And…
J_Ocampo
  • 445
  • 1
  • 7
  • 18
0
votes
1 answer

Select Case & Try statement infinite loop

When trying to print a report in my vb.net project, I have some code to check whether all of the required fields have been filled in. If it isn't, a message box appears to notify the user. When they press 'OK', I need the program to stop executing…
David
  • 2,298
  • 6
  • 22
  • 56
0
votes
1 answer

Why If statement is repeat for twice?

I have a "if" or "case" statement in the a method that I can called. I have "Flag" varriable as public status. Its Crazy its loop/running for twice, so cause have duplicate command, in these case I have duplicate data on the database. Public Sub…
MFBM
  • 145
  • 1
  • 1
  • 7
0
votes
1 answer

Run Time Error 9 with Select Case

Sometimes the below script works, but generally it yields the error message in the title. I have set watches on the objects and variables, and they all appear to be defined and/or have proper values when the error occurs, so it is baffling. Any…
Brian
  • 1
  • 1
0
votes
0 answers

VBA concatenate a dynamic range

I have a dynamic range and I'd like to fix up one range of data using select case, paste it 20 columns right, then concatenate two columns, the fixed up range column and another column in the dynamic range set, which will be pasted 20 columns right,…
0
votes
1 answer

MySQL - on duplicate key - CASE WHEN THEN ELSE doesnt work

I want to insert an entry (uid, A, B) to database. If the entry is existed already, I will update the 'A' and 'B' column with condition: (1 = old entry; [2] = new entry) A = (B[1] == B[2]) ? A[1] : A[2]; B = B[2] + 1; My query: INSERT INTO…
Anh-Tuan Mai
  • 1,129
  • 19
  • 36
0
votes
1 answer

Nested If - ElseIf - Select Case

I need to choice a way to write a piece of code that will repeated very much so I want it to be as fast as possible. This is my code (at the moment): For Cel As Short = 0 To Cels - 1 Rw = Int(Cel / 3) + 1 Col = Cel - ((Rw - 1) * 3) + 1 …
genespos
  • 3,211
  • 6
  • 38
  • 70
0
votes
3 answers

VB Select Case if textbox string, elif textbox numeric (isnumeric not working)

Am using program which must treat user input differently, depends whether on number or string. Select Case and IsNumeric are not working as expected. I get this code when animal=a char or string. Error: An unhandled exception of type…
user4974730
0
votes
1 answer

Select Case Less Than or Equal To

Very new to VBA and so am trying to gain experience by creating a tax calculator macro, but I'm not sure why the values aren't being generated in the right cells or if this is even the best way to go about the tax bracket calculator. Sub…
Phil Hong
  • 1
  • 1