C# 10進位/十進位 轉 2進位/二進位 轉 UI(checkbox)

C# 10進位/十進位 轉 2進位/二進位 轉 UI(checkbox)

C# 10進位/十進位 轉 2進位/二進位 轉 UI(checkbox)


                intDecBuf00 = Convert.ToInt32(Strlocal_input_state_record_flags);
                intD2BCount = 0;
                do
                {
                    intDecBuf01 = intDecBuf00 % 2;
                    intDecBuf00 = intDecBuf00 / 2;
                    switch (intD2BCount)
                    {
                        case 00:
                            ckbSub000001_16.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_16.Checked = true;
                            }
                            break;
                        case 01:
                            ckbSub000001_17.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_17.Checked = true;
                            }
                            break;
                        case 02:
                            ckbSub000001_18.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_18.Checked = true;
                            }
                            break;
                        case 03:
                            ckbSub000001_19.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_19.Checked = true;
                            }
                            break;
                        case 04:
                            ckbSub000001_20.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_20.Checked = true;
                            }
                            break;
                        case 05:
                            ckbSub000001_21.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_21.Checked = true;
                            }
                            break;
                        case 06:
                            ckbSub000001_22.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_22.Checked = true;
                            }
                            break;
                        case 07:
                            ckbSub000001_23.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_23.Checked = true;
                            }
                            break;
                        case 08:
                            ckbSub000001_24.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_24.Checked = true;
                            }
                            break;
                        case 09:
                            ckbSub000001_25.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_25.Checked = true;
                            }
                            break;
                        case 10:
                            ckbSub000001_26.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_26.Checked = true;
                            }
                            break;
                        case 11:
                            ckbSub000001_27.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_27.Checked = true;
                            }
                            break;
                        case 12:
                            ckbSub000001_28.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_28.Checked = true;
                            }
                            break;
                        case 13:
                            ckbSub000001_29.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_29.Checked = true;
                            }
                            break;
                        case 14:
                            ckbSub000001_30.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_30.Checked = true;
                            }
                            break;
                        case 15:
                            ckbSub000001_31.Checked = false;
                            if (intDecBuf01 == 1)
                            {
                                ckbSub000001_31.Checked = true;
                            }
                            break;
                    }
                    intD2BCount++;
                } while (intD2BCount < 16);    














備註:

短除法/取餘數/取商/switch-case/do-while

One thought on “C# 10進位/十進位 轉 2進位/二進位 轉 UI(checkbox)

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *