因此,我试图在代码中显示一些标志,它们只是文本框或标签。如何让它们同时显示多个标志,而不必单击我的按钮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();发布于 2013-10-14 03:07:14
试着移动:
if (textBox18.Text == "1")
{
OverflowFlag.Visible = true;
}紧跟其后
textBox18.Text = binary[0].ToString();https://stackoverflow.com/questions/19352901
复制相似问题