我尝试做这样的事情
sub test()
a=inputbox("value1:")
b=inputbox("value2:")
c=inputbox("value3:")
if a<b and a>c then
msgbox(a)
else
msgbox(b)
msgbox(c)
end if
end sub
当我输入 a 为 5、b 为 10、c 为 2 等值时,条件应返回 TRUE,然后显示带有 a 的消息框,但它返回 FALSE 并显示带有 b 和 c 的消息框。我认为解决方案非常简单,但我无法弄清楚。
多谢
您的输入框返回看起来像数字的字符串,"5"
不小于"10"
。执行以下操作之一:
Dim a as long, b as long, c as long
- Use 应用程序.输入框 https://learn.microsoft.com/en-us/office/vba/api/excel.application.inputbox使用 Type:=1 参数。
- 将字符串转换为实数,例如
a=clng(inputbox("value1:"))
or if int(a)<int(b) and int(a)>int(c) then
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)