How to get collection item by index?


How to access item in collection? Next code gives me error in last line.

<package> <job id="NonDisabledServicesCollecting"> <COMMENT> ************************************************************ 1 comment 2 3 ************************************************************ </COMMENT> <script language="VBScript"> flash_folder="I:\123\" str_flash_folder_colFiles = "" num_flash_folder_colFiles = 0 Set flash_folder_colFiles = CreateObject("Scripting.FileSystemObject").GetFolder(flash_folder).Files WScript.Echo flash_folder_colFiles(1) For Each flash_folder_objFile in flash_folder_colFiles num_flash_folder_colFiles = num_flash_folder_colFiles + 1 str_flash_folder_colFiles = str_flash_folder_colFiles + cstr(num_flash_folder_colFiles) + " " + flash_folder_objFile.Name + vbCrLf Next Dim response Do response = InputBox("Please enter the number that corresponds to your selection:" + vbCrLf + str_flash_folder_colFiles, "Choose DLL to copy...") If response = "" Then WScript.Echo "Input is empty." 'Detect Cancel If IsNumeric(response) Then Exit Do 'Detect value response. WScript.Echo "You must enter a numeric value." Loop selected_flush_DLL = flash_folder + flash_folder_colFiles(cint(response)) WScript.Echo selected_flush_DLL </script> </job> </package>


The .Files collection can't be accessed by index:

>> Set oFiles = goFS.GetFolder(".\").Files >> n = oFiles(0).Name >> Error Number: 5 Error Description: Invalid procedure call or argument

You need a For Each loop to fill a random access collection e.g. an Array:

>> Set oFiles = goFS.GetFolder(".\").Files >> ReDim aFiles(oFiles.Count - 1) >> i = 0 >> For Each oFile In oFiles >> Set aFiles(i) = oFile >> Next >> n = aFiles(0).Name >> WScript.Echo n >> 31823568.notes


  • Extract text between HTML tags
  • Open Sharepoint Excel Files With VBA
  • Use VBScript to Merge all open instances of Notepad.exe and save to txt file
  • How to convert all *.potx files to *.pptx files with VBA?
  • How to find last modified subfolder?
  • Moving and Renaming Files Using VBScript
  • Create Virtual Directory IIS7 to be use in GetFolder in Server.CreateObject(“Scripting.FileSystemObj
  • VBS script to rename files using the pathname
  • Read Recent and Unseen message using javax.mail
  • Issue processing MailDir format with Java on Windows
  • Creating a table in “MSWord” document out of a text in a .txt file
  • DotNet version of Windows Scripting Host
  • Accessing the raw code in an MS Access application
  • How do you copy a MS SQL 2000 database programmatically using C#?
  • Get specific string
  • How to make jdk.nashorn.api.scripting.JSObject visible in plugin [duplicate]
  • How does this usort cmp function actually work?
  • Stop Bash Script if Hive Fails
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Get one-time binding to work for ng-if
  • How do I change content of ComboFieldEditor?
  • Adding a button at the bottom of a table view
  • How can I send an e-mail from a vbs script
  • Spring security and special characters
  • Ajax jQuery multiple calls at the same time - long wait for answer and not able to cancel
  • How do I fake an specific browser client when using Java's Net library?
  • Date difference with leap year
  • angularjs unit test when to use $rootScope.$new()
  • Volusion's generic SQL folder, functionality
  • Menu Color Fade on Hover with Jquery
  • How to limit post in wp_query
  • Hazelcast - OperationTimeoutException
  • Display Images one by one with next and previous functionality
  • How to make Safari send if-modified-since header?
  • Upload files with Ajax and Jquery
  • Adding custom controls to a full screen movie
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • reshape alternating columns in less time and using less memory