且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

复杂方程函数问题

更新时间:2023-02-26 20:39:28

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


那么你的循环就是:
展开 | 选择 | 换行 | 行号


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


登录 关闭
扫码关注1秒登录
复杂方程函数问题
发送“验证码”获取 | 15天全站免登陆
上一篇 : :月相差YYYYMM pandas下一篇 : 转换EEE MMM dd HH:mm:ss ZZZ yyyy到YYYY-MM-dd JAVA

相关阅读

技术问答最新文章