下面一段
string c, d;
switch (tbPlcPointAdress.Text.Length)
{
case 1:
c = "000" + tbPlcPointAdress.Text;
break;
case 2:
c = "00" + tbPlcPointAdress.Text;
break;
case 3:
c = "0" + tbPlcPointAdress.Text;
break;
case 4:
c = tbPlcPointAdress.Text;
break;
default:
c = "0000";
break;
}
直接改為
string c, d;
c = tbPlcPointAdress.Text;
c = c.PadLeft(4, '0');
就行了
[ 此帖被bifujian110在2017-12-28 15:57重新編輯 ]