嵌套的If和ElseIf语法 [英] Nested If and ElseIf Syntax

查看:51
本文介绍了嵌套的If和ElseIf语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮助!


我正在尝试检查表单是否缺少值。其中两个字段是必需的,因此相应的消息框是VBOkOnly。另外两个用于警告目的,它们的消息框是VBYesNo。


首先代码询问用户是否要保存记录。如果用户回答是,则代码应继续检查错误并允许用户更正错误。一旦纠正了所有错误,消息框显示结束是否测试。应该出现。如果用户回答否,则显示未测试结束的消息框。应该出现。 No部分工作正常但是Yes部分只是部分工作。


Date和CustomerID的检查工作正常。但是,如果选择了1以外的ShipMethodID,则该过程停止并且不检查最终字段(ShipCost)或显示是否结束测试。消息框。


我想我有一个结束如果在错误的地方。


我的代码如下:

HELP!

I''m trying to check a form for missing values. Two of the fields are required and therefore the corresponding message boxes are VBOkOnly. The other two are for warning purposes and their message boxes are VBYesNo.

First the code asks if the user wants to save the record. If the user answers Yes, the code should proceed to check for errors and allow the user to correct them. Once all of the errors are corrected a message box display "End of Yes Test" should appear. if the user answers No, a message box displaying "End of No Test" should appear. The No part is working correctly but the Yes part is only partially working.

The checks for Date and CustomerID work fine. However, if a ShipMethodID other than 1 is selected, the process stops and doesn''t check the final field (ShipCost) or display the "End of Yes Test" message box.

I''m think I have an End If in the wrong place.

My code is below:

展开 | 选择 | Wrap | 行号

推荐答案

嗯,我建议的第一件事是正确缩进你的代码。这不仅仅是随机应用,而是在你需要确定你在代码中的位置时非常真实的帮助。


我强烈怀疑这个漏洞会变得明显你完成这件事。如果没有,请重新发布更正后的代码,我们会为您查看。
Well, the first thing I would suggest is to indent your code properly. This isn''t just applied randomly, but is a very real help in situations where you need to determine where you are in the code.

I strongly suspect the flaw will become obvious to you once this is done. If not, repost the corrected code and we will look at it for you.


我不知道如何缩进,您能帮忙吗?
I don''t know how it is suppose to be indented, can you help?


OK。


依赖于If或Else(或者甚至是ElseIf - 一个单词)的所有内容都应该从定义其依赖关系的行中缩进。匹配Elses,ElseIfs和End Ifs都应该处于同一级别。


类似(如果不那么复杂)缩进也应该用于...结束;对......下一个;虽然...... Wend;做......循环;等构造。还有更多,但我希望你能得到概念和想法。


EG
OK.

Everything which is dependant on an If or an Else (or even an ElseIf - one word) should be indented from the lines which define their dependencies. Matching Elses, ElseIfs and End Ifs should all be at the same level.

Similar (if less complicated) indenting should also be done for With ... End With; For ... Next; While ... Wend; Do ... Loop; etc constructs. There are more, but I hope you get the concept and the idea.

EG
展开 | 选择 | 换行 | 行号


这篇关于嵌套的If和ElseIf语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆