Answered by:
in VB how can i write something equvalent to sql's IN

Question
-
User1913822523 posted
In code behind i would like to write something equivalent to sql "IN". Like "WHERE id IN ('1','2','3')..." But I would like to do this for a variable in VB. Like "If string IN ('1','2','3') Then..."
How do I achieve that?
Monday, November 2, 2009 4:42 AM
Answers
-
User-1179452826 posted
Something like this:
Dim arr = New String() {"asd", "jkf"}
Dim result = arr.Contains("asd")- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, November 2, 2009 6:04 AM -
User-1179452826 posted
I thought it was pretty clear...you'd do this:
dim arr = new string(){"string1", "string2"}
IF arr.Contains(yourStringVariable) then
...
Endif
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, November 2, 2009 5:51 PM
All replies
-
User-1179452826 posted
Something like this:
Dim arr = New String() {"asd", "jkf"}
Dim result = arr.Contains("asd")- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, November 2, 2009 6:04 AM -
User1913822523 posted
Something like this:
Dim arr = New String() {"asd", "jkf"}
Dim result = arr.Contains("asd")
I dont quite get it. How can I use this in an IF statement? Like "IF some_string = '1' or '2' or '3'.... Then"
I guess I could write "IF some_string = '1' or some_string = '2' or some_string = '3' Then" But I just thought there had to be a better way of achieving this.
Monday, November 2, 2009 1:36 PM -
User-1179452826 posted
I thought it was pretty clear...you'd do this:
dim arr = new string(){"string1", "string2"}
IF arr.Contains(yourStringVariable) then
...
Endif
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, November 2, 2009 5:51 PM -
User1913822523 posted
thanks, i had a typo which caused an error. Thanks!
Monday, November 2, 2009 6:18 PM