Yes iterating through each item is the ultimate solution though. But here is
another way,

Select Case iInput
   Case 2, 22, 66, 97, 105
       ' do this
   Case Else
       ' do that
End Select

On Sat, Oct 16, 2010 at 7:07 PM, Cerebrus <[email protected]> wrote:

> ---
> Private Sub CodeRed(ByVal iInput As Integer)
>  Dim launchCodes() As Integer = New Integer() {2, 22, 66, 97, 105,
> 190}
>  Array.Sort(launchCodes)
>
>  Dim found As Integer = Array.BinarySearch(launchCodes, iInput)
>  If (found > -1) Then
>    'The launchCode matched. Launch the nukes. Yippeee!
>    LaunchTheNukes()
>  Else
>    'The launchCode is fake. Maybe next time... HeHeHe
>  End If
> End Sub
>
> ---
>
> On Oct 15, 3:53 am, Phil <[email protected]> wrote:
> > Hopefully a simply question on vb.net syntax.
> > I have a variable, lets call it iInput, which is an integer.
> > If iInput is one of several values, for example 2,22,66,97,105 or 190
> > then I have to do something.
> >
> > Is there a simple way to do this check?
> >
> > I seem to remember from VB that there's somethng like
> > If iInput in [2,22,66,97,105,190] or maybe using () instead.
> >
> > I'm trying to find a more elegant way to do this than
> >
> > If iInput = 2 or iInput = 22 or iInput = 66 .... then
> >
> > Is there a neat way to do this?
> >
> > Thanks
> >
> > Phil.
>

Reply via email to