Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 按下按钮时的消息框确认_Vb.net_Forms_Button - Fatal编程技术网

Vb.net 按下按钮时的消息框确认

Vb.net 按下按钮时的消息框确认,vb.net,forms,button,Vb.net,Forms,Button,无论我在消息框中按是或否,我的代码都会清除。我相信我可能也能摆脱我的if语句,我不知道为什么我会这样把它们包括进去 Private Sub btnClear\u单击(发送者作为对象,e作为事件参数)处理btnClear。单击 如果MsgBox(“您确定吗?”,MessageBoxButtons.YesNo,MessageBoxIcon.Question=DialogResult.Yes),则 如果(chkLevel3Support.Checked),则 chkLevel3Support.Chec

无论我在消息框中按是或否,我的代码都会清除。我相信我可能也能摆脱我的if语句,我不知道为什么我会这样把它们包括进去

Private Sub btnClear\u单击(发送者作为对象,e作为事件参数)处理btnClear。单击
如果MsgBox(“您确定吗?”,MessageBoxButtons.YesNo,MessageBoxIcon.Question=DialogResult.Yes),则
如果(chkLevel3Support.Checked),则
chkLevel3Support.Checked=False
如果结束
如果(chkOnSiteTraining.Checked),则
chkOnSiteTraining.Checked=False
如果结束
如果(chkCloudBackup.Checked),则
chkCloudBackup.Checked=False
如果结束
如果(rdbYearlyLicense.Checked)那么
rdbYearlyLicense.Checked=False
如果结束
如果(rdbOneTIme.Checked)那么
rdbOneTIme.Checked=False
如果结束
lbCostofLicenseOutput.Text=“”
lbCostofOptionalOutput.Text=“”
lbTotalCostSale.Text=“”
如果结束
端接头

我想你的右括号放错地方了。试试这个:

If MsgBox("Are you sure?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question) = MsgBoxResult.Yes Then
或者按照Andrew建议的.NET方式进行:

If MessageBox.Show("Are you sure?", "Confirm clear", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then

您提供的代码没有MessageBox。你的意思是包括注释代码吗?请将其修复,使其代表您的实际代码。请使用,让Visual Studio告诉您问题所在。检查
chkLevel3Support没有任何意义。已检查
,依此类推,如果它必须以
False
结束。@AndrewMorton不要忘记CheckState.Intermediate:)
chkLevel3Support.CheckState=CheckState.undeterminate
如果chkLevel3Support.Checked,那么chkLevel3Support.Checked=False
@djv-Lol,我想没有人确定这是否在规范中:)关闭,但是第二个参数应该是
MsgBoxStyle
。不严格使用选项的危险是多方面的。这就解决了它!我可以相信我花了这么长时间,并没有注意到!我很感激it@AndrewMorton这也是依赖记忆而不仔细阅读的危险。