Hemanth Kumar
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("WScr ipt.Shell" ) set wshNetwork = WScript.CreateObject("WScr ipt. Network") set objStdOut = wscript.stdout set FileSysObj = CreateObject("Scripting. FileSystemObject")
set FSOComputerList = FileSysobj.Opentextfile("D :\USI.Data \Computers Dump.txt", ForReading ,False,-1) ComputerIndex=0 dummy=FSOComputerList.read line wscript.echo dummy Do Until FSOComputerList.AtEndOfStr eam StrInputLine=FSOComputerLi st.ReadLin e if len (trim(strinputline)) > 0 then ComputerIndex = ComputerIndex + 1 AryComputer(ComputerIndex, 1) = Trim(Ucase(Left(StrInputLi ne,20))) AryComputer(ComputerIndex, 2) = Trim(Mid(StrinputLine,20)) AryComputer(ComputerIndex, 3) = 0 end if Loop FSOComputerList.close
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("WScr
set FSOComputerList = FileSysobj.Opentextfile("D
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Because I do have the line like
if len (trim(strinputline)) > 0 then
if len (trim(strinputline)) > 0 then
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks,
After changing the array size value and handling the null value its running now. I will report If I get any error.
After changing the array size value and handling the null value its running now. I will report If I get any error.
ASKER
will u be able to tell me with example and the reason of this error?