gpt4 book ai didi

vbscript - 检查某个值是否在数字列表中

转载 作者:行者123 更新时间:2023-12-02 20:23:38 25 4
gpt4 key购买 nike

假设我有一组数字 23,56,128,567,我必须应用一个条件逻辑,其中如果变量 myData 存在于上述数字组中,则只有我继续,否则我不' t。

抱歉,必须研究一些遗留代码,并且不确定如何在 VBScript 中执行此操作。

最佳答案

您可以将值放入 Dictionary 中:

Set list = CreateObject("Scripting.Dictionary")
list.Add 23, True
list.Add 56, True
list.Add 128, True
list.Add 567, True

然后检查你的值是否存在于字典中:

If list.Exists(myData) Then
'do stuff
End If

ArrayList将是另一种选择:

Set list = CreateObject("System.Collections.ArrayList")
list.Add 23
list.Add 56
list.Add 128
list.Add 567

If list.Contains(myData) Then
'do stuff
End If

关于vbscript - 检查某个值是否在数字列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27931672/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com