0

所以我试图在我的代码中显示一些标志,它们只是文本框或标签。如何让他们同时显示多个标志而无需单击我的按钮 2 次?

下面的代码是一个 8 位寄存器的设置,8 位输​​入 A,8 位输​​入 B。我想输出 8 位,并且想显示一个进位标志,如果另外使用了进位,然后溢出,如果有溢出。我遇到的问题是同时显示溢出和进位标志,而无需单击按钮 2 次。

textBox29.Visible = false;
textBox30.Visible = false;
string registera, registerb;
registera = textBox1.Text + textBox2.Text + textBox3.Text + textBox4.Text + textBox5.Text + textBox6.Text + textBox7.Text + textBox8.Text;
registerb = textBox26.Text + textBox25.Text + textBox24.Text + textBox23.Text + textBox22.Text + textBox21.Text + textBox20.Text + textBox19.Text;
int output = Convert.ToInt32(registera, 2);
int output2 = Convert.ToInt32(registerb, 2);
output = output + output2;
string binary = Convert.ToString(output, 2);

for (int i = 7; i >=1; i--)
{
    if (registera[i] == '1' && registerb[i] == '1')
    {

        Carryflag.Visible = true;
     }
}   


if (output == 0)
{
    textBox28.Visible = true;
}
else textBox28.Visible = false; 

if (output > 255)
{
    Carryflag.Visible = true;
}

if (textBox18.Text == "1")
{
    OverflowFlag.Visible = true;
}



binary = binary.PadLeft(9, '0');

textBox18.Text = binary[0].ToString();
textBox16.Text = binary[1].ToString();
textBox15.Text = binary[2].ToString();
textBox14.Text = binary[3].ToString();
textBox13.Text = binary[4].ToString();
textBox12.Text = binary[5].ToString();
textBox11.Text = binary[6].ToString();
textBox10.Text = binary[7].ToString();
textBox9.Text = binary[8].ToString();
4

1 回答 1

0

尝试移动:

 if (textBox18.Text == "1")
 {
    OverflowFlag.Visible = true;
 }

紧接着

textBox18.Text = binary[0].ToString();
于 2013-10-14T03:07:14.303 回答