【发布时间】:2011-11-29 11:15:58
【问题描述】:
我的代码如下:
If (InStr(1, "ALL", Itype) Or InStr(1, Uvar.Device, Itype) _
And (InStr(1, "ALL", Isec) Or InStr(1, Uvar.Sec, Isec)) _
And (InStr(1, "ALL", Idev) Or InStr(1, Uvar.Model, Idev)) Then Useline = "TRUE"
稍微扩展一下:
Itype 是一个长字符串,例如-
-
Itype = All, Apple, Pear, Orange Isec = dog, cat, duckIdev = tree, flower, plant
每个 UVar.x 都是一个单词,例如-
UVar.Device = AppleUVar.Sec = CatUVar.Model = tree
所以,如果 Itype 包含字符串“All”或者它包含 UVar.Device 的值 并且 Isec 还包含字符串“All”或者它包含 UVar.Sec 的值 并且 IDev 还包含字符串“All”或者它包含 UVar.Model 的值
那么我想要if statement = true。
我上面的代码似乎返回 true 无论使用什么值,只要至少一个值标准集匹配。
因此,字符串 IType、Idev 和 Isec 是否都包含值“all”或特定的用户定义值?
【问题讨论】:
标签: vba if-statement