private void Button_Set_Click(object sender, EventArgs e)
{
if (mc100_open(0) < 0)
{
MessageBox.Show("打开设备失败!");
return;
}
byte value;
value = 0;
value |= (byte)(Track_PA0.Value << 0);
value |= (byte)(Track_PA1.Value << 1);
value |= (byte)(Track_PA2.Value << 2);
value |= (byte)(Track_PA3.Value << 3);
value |= (byte)(Track_PA4.Value << 4);
value |= (byte)(Track_PA5.Value << 5);
value |= (byte)(Track_PA6.Value << 6);
value |= (byte)(Track_PA7.Value << 7);
mc100_write_port(0, MC100_PORTA, value);
value = 0;
value |= (byte)(Track_PB0.Value << 0);
mc100_write_port(0, MC100_PORTB, value);
value = 0;
value |= (byte)(Track_PC0.Value << 0);
value |= (byte)(Track_PC1.Value << 1);
value |= (byte)(Track_PC2.Value << 2);
value |= (byte)(Track_PC3.Value << 3);
value |= (byte)(Track_PC4.Value << 4);
mc100_write_port(0, MC100_PORTC, value);
value = 0;
if (Check_PPA0.Checked) value |= (byte)(1 << 0);
if (Check_PPA1.Checked) value |= (byte)(1 << 1);
if (Check_PPA2.Checked) value |= (byte)(1 << 2);
if (Check_PPA3.Checked) value |= (byte)(1 << 3);
if (Check_PPA4.Checked) value |= (byte)(1 << 4);
if (Check_PPA5.Checked) value |= (byte)(1 << 5);
if (Check_PPA6.Checked) value |= (byte)(1 << 6);
if (Check_PPA7.Checked) value |= (byte)(1 << 7);
mc100_set_push_pull(0, MC100_PORTA, value);
value = 0;
if (Check_PPB0.Checked) value |= (byte)(1 << 0);
mc100_set_push_pull(0, MC100_PORTB, value);
value = 0;
if (Check_PPC0.Checked) value |= (byte)(1 << 0);
if (Check_PPC1.Checked) value |= (byte)(1 << 1);
if (Check_PPC2.Checked) value |= (byte)(1 << 2);
if (Check_PPC3.Checked) value |= (byte)(1 << 3);
if (Check_PPC4.Checked) value |= (byte)(1 << 4);
mc100_set_push_pull(0, MC100_PORTC, value);
value = 0;
if (Check_PUA0.Checked) value |= (byte)(1 << 0);
if (Check_PUA1.Checked) value |= (byte)(1 << 1);
if (Check_PUA2.Checked) value |= (byte)(1 << 2);
if (Check_PUA3.Checked) value |= (byte)(1 << 3);
if (Check_PUA4.Checked) value |= (byte)(1 << 4);
if (Check_PUA5.Checked) value |= (byte)(1 << 5);
if (Check_PUA6.Checked) value |= (byte)(1 << 6);
if (Check_PUA7.Checked) value |= (byte)(1 << 7);
value = (byte)~value;
mc100_set_pull_up(0, MC100_PORTA, value);
value = 0;
if (Check_PUB0.Checked) value |= (byte)(1 << 0);
value = (byte)~value;
mc100_set_pull_up(0, MC100_PORTB, value);
value = 0;
if (Check_PUC0.Checked) value |= (byte)(1 << 0);
value = (byte)~value;
mc100_set_pull_up(0, MC100_PORTC, value);
mc100_close(0);
Button_Refresh_Click(new object(), new EventArgs());
}
------解决思路----------------------
自己试着转一下吧
http://www.developerfusion.com/tools/convert/csharp-to-vb/