复杂方程函数问题 [英] Complicated Equation Function Problem

查看:65
本文介绍了复杂方程函数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我之前使用您的所有帮助创建的方程函数有一点问题。该功能本身很好,但内部有一个小故障。


这是功能代码。

展开 | 选择 | Wrap | 行号

解决方案

您是否尝试过替换功能?它也可以处理同一个变量的多次出现。


那么你的循环就是:

展开 | 选择 | 换行 | 行号


Hi Constantine AI。问题似乎是因为在第19行中使用了Instr(您自编辑代码后发布了!!)以找到匹配参数的名称。如果两个参数在某些点上具有相同的字符,例如 DoorT DoorT H,则Instr将与较短的名称匹配。如果它首先找到DoorTH,那么它将被用来代替DoorT,因此你的错误。


如果你使用参数表,最好为每个参数都有一个显式名称字段您可以使用''=''代替Instr进行完全匹配。从长远来看,这将更加强大,但因为它涉及部分重新设计,为什么不只是重命名一个或其他参数呢?


例如,你可以改变DoorT to Door-T,或DoorTH to Door-TH或其他任何在您的配方环境中有意义的东西。只需确保重命名产生的多个参数没有部分匹配!

-Stewart


PS您编辑的帖子显示您正在使用参数的全名 - 那么为什么要使用Instr?


我猜这行:

展开 | 选择 | Wrap | 行号

Hi i am having a little problem with an equation function that was created from all your help previously. The function works fine itself but with a small glitch within it.

Here is the function code.

Expand|Select|Wrap|Line Numbers

解决方案

Have you tried the Replace Function? It could also handle multiple occurrences of the same variable.

Then your loop would just be:

Expand|Select|Wrap|Line Numbers


Hi Constantine AI. Problem appears to result from using Instr in line 19 (youv''e edited your code since it was posted!!) to find the name of a matching parameter. If two parameters have the same characters up to some point, like DoorT and DoorTH, Instr will match against both for the shorter name. If it finds DoorTH first then it will be used instead of DoorT, hence your error.

If you are using a parameters table it would be better to have an explicit name field for each parameter on which you can do a full match using ''='' instead of Instr. In the longer term this will be far more robust, but as it would involve a partial redesign why not just rename one or other parameter something else throughout?

For example, you could change DoorT to Door-T, or DoorTH to Door-TH or anything else that would make sense in the context of your formula. Just make sure that there are no partial matches on more than one parameter resulting from the rename!

-Stewart

PS your edited post shows that you ARE using the full name of the parameter - so why use Instr at all?


I''m guessing that the line :

Expand|Select|Wrap|Line Numbers


这篇关于复杂方程函数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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