替代500多行If,Then,Else ...过滤表格 [英] Alternative to 500+ lines of If, Then, Else... To Filter Form

查看:74
本文介绍了替代500多行If,Then,Else ...过滤表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在努力尝试通过代码来获取表单来过滤另一个表单。我知道代码的工作规模较小......但是怀疑有更好的写作方式。在我目前的形式中,我得到了程序太大的说法。过滤代码的错误(有超过500行的If,ElseIf语句)。


目前,过滤表单有9个控制字段用于过滤另一个表单。例如,其中一个控件是建筑物列表。选择建筑物后,相关的表格将被建筑物过滤。当另一个控件除了构建过滤器之外还选择了一个项目...说房间类型,过滤器将堆叠并仅显示具有该特定类型房间的建筑物(所有过滤器控件堆叠过滤器)。

为了让您了解我编写的代码:

Hello,

I''m struggling w/ trying to get a form to filter another form through code. I know the code works on a smaller scale... but have a suspicion that there is a better more efficient way of writing it. In my current form I get the "Procedure too large" error for the filtering code (There are over 500 lines of If, ElseIf statements).

Currently, the filtering form has 9 control fields to use to filter another form. So for instance, one of the controls is a list of buildings. When a building is selected the associated form is filtered by buildings. When another control has an item selected in addition to the building filter... say room type, the filter would stack and show only buildings with rooms of that specific type (all filter controls stack the filter).

To give you an idea of the code that I''ve written:

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号

推荐答案

Vaulcul,

感谢您提出一个有趣的问题。下面是一些代码,它将遍历表单上的所有列表框并动态生成过滤字符串。我没有测试过,所以它的价格可能不超过收取的价格。

Vaulcul,
Thanks for an interesting question. Here is some code that will loop through all the list boxes on the form and dynamically make filter string. I haven''t tested it, so it may be worth no more than the price charged.

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号


jimatqsi,


哇!这是非常棒的代码,我不知道我能做到这一点(仍然教我的大脑像程序员一样思考)。我对你提供的内容进行了很少的编辑。


我最终得到的代码是:

jimatqsi,

Wow! That''s awesome code, I had no idea I could do that (still teaching my brain to think like a programmer). I made very few edits to what you provided.

The code I ended up with was:

展开 | 选择 | Wrap | 行号


在完成的代码中重复第6行到第14行

更改重复行7以检查文本框类型

更改重复行8检查null或zerolength sring

(参见这篇文章:什么是Null?

基本按原样使用9到11的重复行。


发布如果您遇到任何错误发生的问题以及确切的数字和描述,请回复更改的代码。
Duplicate lines 6 thru 14 in your finished code
Alter duplicate line 7 to check for text box type
Alter duplicate line 8 to check for null or zerolength sring
(see this article: What is Null?)
Use duplicate lines 9 thru 11 basically as is.

Post back altered code if you run into issues along with the line where any error occurs and the exact number and description.


这篇关于替代500多行If,Then,Else ...过滤表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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