Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello friends,
I was bit stuck in finding out particular value in range, Say.

(121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,166,167,177,178,185,188,189,190,191,193,197,198,199,213,214,215,223,224,228,229,230,231,240,241,244) 


I have tried in IF clause

If dropdownlistChargingCategoryCreative1to3 in (121, 122, 123, 124, 125, 126, 127. . . .) then

            End If


not any worth, Any idea about it?

Thanks in advance
Posted

If your range is a comma-delimited string, you could do it a number of ways, but the best/simplest would be something like this:

C#
string myRange = "(121, 122, ..., 244)";

private bool InRange()
{
    myRange = myRange.Replace(")","").Replace(")","");
    string[] parts = myRange.Replace(" ", "").Split(',');
    int count = (from part in parts
                 where part == dropdownlistChargingCategoryCreative1to3
                 select part).Count();
    return (count > 0);
}
 
Share this answer
 
v2
Comments
Manfred Rudolf Bihy 6-Apr-11 9:17am    
I think you missed the opening and closing parenthesis which would cause 121 and 244 not to be recognized.

:)
FTFY
Wild-Programmer 6-Apr-11 9:18am    
Awersome +5
dhage.prashant01 7-Apr-11 1:45am    
Dim count As Integer = (From part In parts Where part = dropdownlistChargingCategoryCreative1to3part).Count()

Above line is giving me error:
Expression of type '1_dimensional array of string' is not queryable.

where m going wrong?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900