Check if the value is in the list of numbers

Let's say I have a group of numbers 23,56,128,567, and I need to apply conditional logic in which, if a variable myDataexists in the group of numbers above, then I continue, otherwise I do not.

Sorry, you need to learn some outdated codes and do not know exactly how to do this in VBScript.

+4
source share
3 answers

You can put the values ​​in Dictionary:

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

and then check if your value exists in the dictionary:

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

And there ArrayListwill be another option:

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
+9
source

Serenity , , .

:

If instr("|23|56|128|567|","|" & myData & "|") then ...

,

+1
If instr("23,56,128,567", myData) then ...

vbscript, .

-3
source

All Articles