|
-
Jan 19th, 2004, 04:18 PM
#1
Thread Starter
Junior Member
comparing against a range of values
Does anyone know of a way to a compare a single value against a range of values, like you can do with the SQL IN() statement?
In SQL you can say:
SELECT * FROM tblAddress WHERE ZipCode IN('92131', '92156', '92163')
and you will get any rows that have a ZipCode value matching any of the values in the brackets.
In vb.net I want to say:
If strZipCode In("92131", "92156", "92163") Then
'do some stuff here
End If
but obviously there is no "In" statement in vb.net. I also want to get away from saying:
If strZipCode = "92131" Or strZipCode = "92156" Or strZipCode = "92163" Then
'do some stuff here
End If
This gets messy when there are many values.
Any suggestions would be appreciated.
-
Jan 19th, 2004, 05:38 PM
#2
Hi Denny.
I think this will do the trick...
VB Code:
Dim S() As String = New String() {"92131", "92156", "92163"}
If Array.IndexOf(S, strZipCode) <> -1 Then
MsgBox("Found")
End If
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Jan 19th, 2004, 06:44 PM
#3
Thread Starter
Junior Member
I think that will do it. Thanks for your help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|