From: Mr. X. on
Hello.
What is the correct syntax in VB.NET for checking that a value is in set of
value ?
pseudo code :
value in ('a','b','c') ...

Thanks :)

From: Andrew Morton on
Mr. X. wrote:
> What is the correct syntax in VB.NET for checking that a value is in
> set of value ?
> pseudo code :
> value in ('a','b','c') ...

What sort of set? If it's a List, then

If myList.Contains(someValue) Then...

--
Andrew


From: Mr. X. on
What I meant is :
dim a as integer
....
a = 3

What should I do instead of :
if a = 1 or a = 2 or a = 5 or a = 18 or a = 33
The pseudo code for short solution is :
if a in (1,2,5,18,33) ...
but the above does't work in VB.NET.
What should I write instead of above ?

Thanks :)

"Andrew Morton" <akm(a)in-press.co.uk.invalid> wrote in message
news:88jff8FeftU1(a)mid.individual.net...
> Mr. X. wrote:
>> What is the correct syntax in VB.NET for checking that a value is in
>> set of value ?
>> pseudo code :
>> value in ('a','b','c') ...
>
> What sort of set? If it's a List, then
>
> If myList.Contains(someValue) Then...
>
> --
> Andrew
>
From: Phill W. on
On 26/06/2010 19:15, Mr. X. wrote:

> What should I do instead of :
> if a = 1 or a = 2 or a = 5 or a = 18 or a = 33
> The pseudo code for short solution is :
> if a in (1,2,5,18,33) ...
> but the above does't work in VB.NET.
> What should I write instead of above ?

Dim values As New List(Of Integer)(New Integer() {1,2,5,18,33})
If (values.Contains(a)) Then
. . .

HTH,
Phill W.
From: Mr. X. on
If this is the only solution, so I shall manage it.
but it seems too complicated writing this on code - it's a basic thing.
Each time I need this I shall write "
if (new list(of integer)(New integer(){1,2,5,18,13}).contains(a) ...

Thanks :)

"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-k> wrote in message
news:i0a1al$d1q$2(a)south.jnrs.ja.net...
> On 26/06/2010 19:15, Mr. X. wrote:
>
>> What should I do instead of :
>> if a = 1 or a = 2 or a = 5 or a = 18 or a = 33
>> The pseudo code for short solution is :
>> if a in (1,2,5,18,33) ...
>> but the above does't work in VB.NET.
>> What should I write instead of above ?
>
> Dim values As New List(Of Integer)(New Integer() {1,2,5,18,33})
> If (values.Contains(a)) Then
> . . .
>
> HTH,
> Phill W.