excel - 比较不是真的;但发送到 MsgBox 的值显示它应该是
问题描述
这是我的代码的一部分..
'Loop through each SOP audit file
For Each oFile In oFiles
'MsgBox (RemoveLeadingZeroes(Split(oFile.Name, "-")(2)))
'Loop through all SOP IDs stored in COL A
For Each cel In SOPID
MsgBox (RemoveLeadingZeroes(Split(oFile.Name, "-")(2)) & " : " & cel)
'See if SOP ID in COL A matches SOP ID in Audit file name
If RemoveLeadingZeroes(Split(oFile.Name, "-")(2)) = cel Then
MsgBox ("Match found on SOP ID: " & cel)
End If
Next cel
Next oFile
这是使用该行比较的值的屏幕截图...
MsgBox (RemoveLeadingZeroes(Split(oFile.Name, "-")(2)) & " : " & cel)
为什么如果两个值确实匹配,则触发 MsgBox 的 If() 语句不表示存在匹配?是否将一个视为字符串,将另一个值视为范围?那会影响它吗?
解决方案
使用 Trim() 删除空格。
推荐阅读
- hook - FeathersJS 防止服务重复的方法
- php - 如何在 Yii 中使用 SetCC
- java - 将文本转换为阿拉伯语
- python - Python:如何将 OpenStreetMaps 中的水道作为图形导入,以便使用 networkx 进行图形分析
- react-admin - Ract-Admin:如何修复 react-admin 的版本及其依赖项?
- html - Bootstrap 4 水平和垂直对齐 Font Awesome 图标
- reactjs - 在 React.js 中更新道具后的启动间隔
- python - 如何使用另一个字典列表更新字典列表?
- javascript - 将 JavaScript 对象(数组)转换为 XML
- sql - Oracle SQL 案例中的无效数字