Take the 2-minute tour ×

In the code provided below, I have a test array. I want to look up for those values which are within the range of 400 to 500 but not found in the Test array (Ex: 410 - Although this value is in the range of 400 to 500, it is not found in the array) Once I find it, I need to add it to a new collection and perform new action (like set the value of it to 410|New-value) to display on the webpage.

Here is the code:

Test= Array("1|Name", "2|Place", "400|Animal", "420|Thing")

For Each x in Test
    'Do Something'          
    'Do Something'

Can anybody help me on this?

share|improve this question

1 Answer 1

Apparently you have key/value pairs there, so the appropriate data structure is probably a dictionary:

Set dict = CreateObject("Scripting.Dictionary")
For Each x in Test
  xSplit = Split(x, "|")
  dict.Add xSplit(0), xSplit(1)

That way you can easily check if a key value is present or not:

If dict.Exists(42) Then
  WScript.Echo dict(42)
  WScript.Echo "Index 42 does not exist."
End If
share|improve this answer

Your Answer


