ソース添削
2017-02-12
どうしてこんな気持ち悪い書き方するのだろう?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
If Button = 2 Then If txtHtml.SelLength > 0 Then mContext.Controls(1).Enabled = True mContext.Controls(2).Enabled = True mContext.Controls(4).Enabled = True Else mContext.Controls(1).Enabled = False mContext.Controls(2).Enabled = False mContext.Controls(4).Enabled = False End If If txtHtml.CanPaste Then mContext.Controls(3).Enabled = True Else mContext.Controls(3).Enabled = False End If mContext.ShowPopup End If |
私ならこう書く
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Dim flg As Boolean If Button <> 2 Then Exit Sub End If With mContext flg = txtHtml.SelLength > 0 .Controls(1).Enabled = flg .Controls(2).Enabled = flg .Controls(4).Enabled = flg flg = txtHtml.CanPaste .Controls(3).Enabled = flg .ShowPopup End With |
←「ドキュメント検査機能では削除できない個人情報とは?」前の記事へ 次の記事へ「ネタ帳」→