Link to home
Start Free TrialLog in
Avatar of Hemanth Kumar
Hemanth KumarFlag for India

asked on

Vbscript subscript out of range error

I have one vbscript(.vbs file) as below. The purpose of it is to compare 2 text file. Here we have declared 2 arrays. while running it im getting error subscript out of range (800A0009)
Error on line. computerindex = computerindex + 1 and in the next line we are doing a trim.

plz advise wht might be the error and solution.

 Const ForReading = 1, ForWriting = 2, ForAppending = 8

Dim AryComputer(5000,3) set Shell = WScript.CreateObject("WScript.Shell") set wshNetwork = WScript.CreateObject("WScript. Network") set objStdOut = wscript.stdout set FileSysObj = CreateObject("Scripting. FileSystemObject")

set FSOComputerList = FileSysobj.Opentextfile("D:\USI.Data\ComputersDump.txt",ForReading,False,-1) ComputerIndex=0 dummy=FSOComputerList.readline wscript.echo dummy Do Until FSOComputerList.AtEndOfStream StrInputLine=FSOComputerList.ReadLine if len (trim(strinputline)) > 0 then ComputerIndex = ComputerIndex + 1 AryComputer(ComputerIndex,1) = Trim(Ucase(Left(StrInputLine,20))) AryComputer(ComputerIndex,2) = Trim(Mid(StrinputLine,20)) AryComputer(ComputerIndex,3) = 0 end if Loop FSOComputerList.close
SOLUTION
Avatar of Jared_S
Jared_S

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hemanth Kumar

ASKER

thanks for the prompt response.

will u be able to tell me with example and the reason of this error?
Because I do have the line like

if len (trim(strinputline)) > 0 then
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks,

After changing the array size value and handling the null value its running now. I will report If I get any error.