我有一个程序,我正在清除用户正在用来回答多项选择题的组合框。如果用户点击清除,弹出消息框并询问用户是否确定要清除表单。如果他们按是,清除所有组合框。截至目前,如果用户按下否,它仍然清除组合框。VB.NET - MessageBox是没有条件声明不起作用
代码:
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
MessageBox.Show("Are you sure you want to clear your answers?", "Attention!", MessageBoxButtons.YesNo)
If Windows.Forms.DialogResult.Yes Then
For Each cbo As ComboBox In Controls.OfType(Of ComboBox)()
cbo.Items.Clear()
Next
End If
End Sub
这将永远不会工作,因为'是= 6'。到目前为止,您的状况如下所示:“If(6 = True)Then'。你需要从'MessageBox.Show'中捕获返回值。 – 2014-09-01 17:15:09
虽然使用'MessageBox.Show'与MsgBox相称! – Plutonix 2014-09-01 17:51:10