For example, if in a text box filled with many different part numbers from the list of materials for computer parts, I want only one type of cat5 cable at any time, and if two different types are visible to alert the user, the cat5 cable part numbers can be: cat5PART # 1, cat5PART # 2 and cat5PART # 3. So, if only one cat5 part number is not noticed, don't worry, but as soon as two different types or more are visible, to warn. I could easily write it manually three different times for each option, but in a wider list of parts, this will take longer and risk errors. Plus, I just wanted to know how programmers handle this type of function. I also don’t know what it's called, so I'm not sure how to do this for Google, even though you knowthat there will be many solutions for this exact situation, so the disappointment is that you need to scare people on the forum for something so simple.
An example of my code, which obviously does not work, because it will only warn about whether all three parts were detected, not only if they were found below. I suppose I would use some options and and | or maybe it's something completely different?
Basically, I don't want to write on a larger scale
if it contains part 1 and part 2
if it contains part 1 and part 3
if it contains part 2 and part 3
Thank.
if ((textBox2.Text.Contains("PART#1"))
&& (textBox2.Text.Contains("PART#2"))
&& (textBox2.Text.Contains("PART#3")))
{
MessageBox.Show("2 types of cat5 part numbers seen at the same time");
}
source
share