检查是否根据是否启用了单选按钮

时间:2017-05-08 16:38:55

标签: vb.net if-statement

我正在制作的调查中有很多单选按钮,调查中有代码可以在错过问题时显示消息:

    ElseIf Not (RadioButton237.Checked Or
            RadioButton238.Checked Or
            RadioButton239.Checked Or
            RadioButton240.Checked Or
            RadioButton241.Checked Or
            RadioButton242.Checked Or
            RadioButton243.Checked) Then

        MsgBox("You missed Question 39")

然而,我现在需要在某些情况下使这个问题变得灰暗,即:如果组合框有选择" no"那么这个问题就是灰色的。我希望我的代码部分检查错过的问题,在这种情况下忽略这些单选按钮,我试图做这样的事情:

ElseIf((RadioButton237.enabled = True,RadioButton237.Checked = false)或 ....然后消息

然而它似乎不起作用。任何建议表示赞赏,我希望我的问题足够明确。

2 个答案:

答案 0 :(得分:1)

您可以使用groupbox对问题的答案进行分组,如果组合框值为“否”,则可以禁用组框...因此,组框中的控件也会被禁用。

然后使用GroupBox.IsEnabled来评估或不评估问题。我认为让事情井井有条更容易跳过问题。但这只是一个快速提示,可能不是最好的方法。

答案 1 :(得分:0)

你是否尝试过这样的事情?

Elseif ((radioButton237.enabled and Not radioButton.checked) or (radioButtonXXX.enabled and Not radioButtonXXX.ckecked) or (radioButtonYYY.enabled and Not radioButtonYYY.ckecked)) then
(...)