VBS如何多个数值文本对比一个文本,求个优雅的写法

  • t
    t526
    x是本机获取到的硬盘编码,abcde是预先写入的硬盘编码。
    msgbox以后打算直接del本程序。

    x=“1”
    a=“2”
    b=“3”
    c=“4”
    d=“5”
    e=“6”
    if x=a then
    elseif x=b then
    elseif x=c then
    elseif x=d then
    elseif x=e then
    else
    msgbox (“erro”)
    end if
  • m
    manhere
    abcde用逗号分割连接在一起,然后用instr判断就行了
  • t
    t526
    回复2#manhere

    这样吗?
    x=“1”
    a=“1,2,3,4,5,6”
    if instr(a,x) < 1 then
    msgbox (“erro”)
    end if
    不知道instr的返回值需不需要赋予变量,等会儿去电脑上试试