Thank you in advance for any help here. This is my first post and I will try to phrase what I am thinking.

I am trying to validate the entry of a field based on entry in a second field.

If field "A" has value 1, 2, or 3 then field "B" (which is a multi entry field) must have two of the values 4, 5, or 6.

Example: A = 1 therefore B must contain 4 & 5. Which would then return a value of true.

Thank you in advance for any help here. This is my first post and I will try to phrase what I am thinking.

I am trying to validate the entry of a field based on entry in a second field.

If field "A" has value 1, 2, or 3 then field "B" (which is a multi entry field) must have two of the values 4, 5, or 6.

Example: A = 1 therefore B must contain 4 & 5. Which would then return a value of true.

it seemed pretty simple to me :

private bool validateB(intA,int B)
{
if(A==1 && (B!=4 || B!5))
{
return false;
}
// rest of the conditions go here
return true;
}

Thank you for the reply. I see how that would work, but I think I'm sill missing something.

I am writing this from a spec sheet and will try to give more details.

I am trying to validate field "A" which is a multi entry field that can contain up to 6 entries. It has the following allowed values.

635, 640, 645, 6120, 6090, 6100, 6110, 6111, and 6112

to validate that the combination of fields entered is ok it must look at field "B" which is a single entry field. It has the following allowed values

995, 1005, 1010, 1015, 1020, 1030

The validation requirement on the spec sheet reads as follows.

"If field "B" is value 995, 1005, or 1010, then field "A" must have at least two (2) values 6090, 6100, or 6110."

I hope that makes it a little clearer.

I'm not sure why Serkan's example was not sufficient, but here is another demonstration. You would need to complete the case labels with the remaining conditional requirements.

public static void Test()
        {
            int [] A = {6090, 6100, 6200};
            bool b = CompareAB(A, 995);
            b = CompareAB(A, 1005);
        }
        public static bool CompareAB(int[] A, int B)
        {
            switch (B)
            {
                case 995:
                case 1005:
                case 1010:
                    if (A.Contains(6090) && (A.Contains(6100) || A.Contains(6110)))
                        return true;
                    break;
                case 1015:
                case 1020:
                case 1030:
                    break;
            }

            return false;
        }

Thank you both very much, having those examples is exactly what I needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.