title: VBscript create array but omit blank variables
body: <p>I am looking to create a script that will compare the last modified date of up to 4 files then capture the one most recently modified. My current road block is that some files might not exist. </p>
  
  <p>The set will fail if the file does not exist but I can easily overcome that by looking for the file and if it does not exist simply skip the set command. This would cause the creation of the array to fail because my variable is now blank.
  Any suggestions how to resolve this?</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>Option Explicit  
  Dim objFSO, path, file, recentDate, recentFile, File1, File2, File3, File4, afiles, File1date, date1
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  set File1=objFSO.getfile("c:\temp\file.txt")
  set File2=objFSO.getfile("c:\test\File.txt")
  set File3=objFSO.getfile("c:\users\%profile%\documents\File.txt")
  set File4=objFSO.getfile("c:\users\public\documents\File.txt")
  
  'Prepare variables to store the required information    
  Dim dateMin, dateMax
  date1 = File1.datelastmodified
  wscript.echo date1
  wscript.echo now
      dateMin = date1
      dateMax = date1
  
  afiles = Array( File1.datelastmodified, File2.datelastmodified, File3.datelastmodified, File4.datelastmodified )
  
  Dim i
      For i=1 to UBound(aFiles)
          If aFiles(i) &lt; dateMin Then dateMin = aFiles(i)
          if aFiles(i) &gt; dateMax Then dateMax = aFiles(i)
      Next 
  '
  ' Output Information
     WScript.Echo "Highest: " &amp; CStr( dateMax )
     WScript.Echo " Lowest: " &amp; CStr( dateMin )
  </code></pre>