
Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Well this is what I am trying to do
Select Case ID
Case 1,3,5
do....
End Select
Now works with it but I need to read 1,3,5 programmatically from a file and
it doesn't work 'coz it treat 1,3,5 as 135 if I use CInt(str).
Where str is a string = "1,3,5"
So I need to read whatever data is there in a file for these values like
4,5,7,8 into a case statement
Select Case ID
Case 4,5,7,8
do....
End Select
I'm stuck :(
Thanks,
Sonu
>> Dim str As String
>> Dim myParsedInt As Integer
[quoted text clipped - 9 lines]
>
> What single integer do you want to get back, and why?
Jon Skeet [C# MVP] - 03 Mar 2008 16:32 GMT
> Well this is what I am trying to do
>
[quoted text clipped - 16 lines]
>
> I'm stuck :(
Right - your problem is that you're trying to parse it as a single
number. 1, 3, 5 represent three different options. You need to:
1) Split the string by commas
2) Parse each of them as an integer
3) Check if the test ID is equal to *any* of the integers

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
SK - 03 Mar 2008 16:57 GMT
Could you please give an example..?
Thanks
>> Well this is what I am trying to do
>>
[quoted text clipped - 24 lines]
> 2) Parse each of them as an integer
> 3) Check if the test ID is equal to *any* of the integers
Peter Duniho - 03 Mar 2008 18:58 GMT
> Well this is what I am trying to do
>
[quoted text clipped - 6 lines]
> and it doesn't work 'coz it treat 1,3,5 as 135 if I use CInt(str).
> Where str is a string = "1,3,5"
If the string is "1,3,5" and you want to read the string as individual
integers separated by commas, then you may want to use the String.Split()
method to get three different strings, each of which you can parse.
But it's not clear that's actually going to address your question.
In the VB code you posted, the code in the "Case" will be executed if the
integer is _any_ of the three listed. If your file actually specifies a
string reading "1,3,5", does that mean you only want to execute the code
if that string matches _all_ of the options? Does it mean that you want
to execute the code _once_ if the string matches _any_ of the options? Or
does it meant that for each integer in the string, you want to execute the
code in that "Case"? Or perhaps some other possibility I haven't even
mentioned?
As you've asked it, your question is ambiguous and until you state your
question more clearly, no one will be able to provide you with the details
you want.
Pete