excel - Excel VBA Math just not adding up
问题描述
I have a line of code that's working perfectly and getting what I want but I'm a little confused as to how it's doing it??
MyStr = "MANUFACTURER: LIEBHERR"
Here's the code and the result:
?VBA.Right(MyStr, VBA.Len(MyStr) - Application.Find(":", MyStr)-1) = LIEBHERR
Perfect !!!!!!
So here's my question.
?VBA.Len(MyStr) = 22
?Application.Find(":", MyStr)-1 = 12
So combining the two statements above and using the VBA.Right command when I subtract 12 from 22 it looks to me that I should get 10 but.......
?VBA.Len(MyStr) - Application.Find(":", MyStr)-1 = 8
Again, I'm getting what I want but I'm confused as to what I'm missing in my math???
解决方案
它是正确的,问题是你不能自己做Application.Find(":", MyStr)-1
:
VBA.Len(MyStr) - Application.Find(":", MyStr)-1
= 22 - 13 -1
= 9 - 1
= 8
你错误地认为它是:
= 22 - ( 13 - 1 )
推荐阅读
- facebook-graph-api - 参数标签 '(withReadPermission:, from:, handler:)' 不匹配任何可用的重载
- java - Java没有获取数组中保存的值
- javascript - JS(p5.js)画布乘法错误并以奇怪的分辨率绘制
- c# - SaveFileDialog 不断将文件保存到 Document 目录
- python - Google Tag Manager API Python 在创建标签时设置 overrideGaSettings = false
- python - 当我以随机顺序创建随机字符列表时,如何保存该列表以进一步使用该随机字符列表
- json - 无法在 Typescript 和 Angular 中正确发送 json
- java - 如何使用 SharedPreferences 检索已选择的照片
- python - 参数(n_neighbors)的参数值需要是一个序列
- sql - SQL 错误中的复合键联接