I am wondering whether there is a better way of doing this.
I have an inputbox where a user enters a Unique ID that UID is put into 1 of 12 saveboxes.
The user can recall the data from the 12 saveboxes.
The test I want to run is:
Is the UID in the inputbox equal to the any of the saveboxes - if yes - move on to rest of code.
If the inputbox is not equal to the savebox - AND - there are no empty saveboxes. Then send a message.
This is the code that I have that is working - credit to jmcilhinney who gave me the baseline code for another task.
I tried really hard to get this into a single check, using &&, || boolean variables....I tried a lot of things, but this is the only one I could get to work.
I am happy with it, it does the job, but I think, perhaps there is an opportunity to learn something new?
edit, i know, should probably just be x++; it's late and I been working on this for hours....
I have an inputbox where a user enters a Unique ID that UID is put into 1 of 12 saveboxes.
The user can recall the data from the 12 saveboxes.
The test I want to run is:
Is the UID in the inputbox equal to the any of the saveboxes - if yes - move on to rest of code.
If the inputbox is not equal to the savebox - AND - there are no empty saveboxes. Then send a message.
This is the code that I have that is working - credit to jmcilhinney who gave me the baseline code for another task.
C#:
var x = 0;
for (var i = 1; i < 13; i++)
{
var controlNumber = i;
if (panel1.Controls[$"HoldSD{controlNumber}"].Text != sdNobox.Text)
{
x = x + 1;
}
}
for (var i = 1; i < 13; i++)
{
var controlNumber = i;
if (panel1.Controls[$"HoldSD{controlNumber}"].Text != "")
{
x = x + 1;
}
if (x >= 24)
{
MessageBox.Show("Resolve");
return;
}
}
I tried really hard to get this into a single check, using &&, || boolean variables....I tried a lot of things, but this is the only one I could get to work.
I am happy with it, it does the job, but I think, perhaps there is an opportunity to learn something new?
edit, i know, should probably just be x++; it's late and I been working on this for hours....