我一直收到错误“object required'added4'”

时间:2013-10-17 14:49:05

标签: arrays vb.net vbscript compare

我试图创建一个包含两个文件的数组,然后比较两个文件,但我碰到了一堵墙。我不断收到错误"对象需要'已添加4'",我也需要读取两个文件将它们组成一个数组,比较两个并从第二个文件中删除不是&#39 ; t在第一个。 我还想记录我删除的行。

'Reads Approvedshare txt and makes the txt file into an array
        public objFSO 
         Set objFSO = CreateObject("Scripting.FileSystemObject") 
         Dim objTextFile 
         Set objTextFile = objFSO.OpenTextFile _
            ("TXT PATH") 
         do Until objTextFile.AtEndOfStream
            strNextLine = objTextFile.Readline
           public array1 : array1 = trim(strNextLine)
            'wscript.echo "test array : " & array1
           array1 = trim(array1)
            loop


        'Reads current shares txt and also makes that txt into an array
        Set objTextFile2 = objFSO.OpenTextFile _
            ("SECOND TXT PATH")
         do Until objTextFile2.AtEndOfStream
        strNextLine2 = objTextFile2.Readline
       public array2 : array2 = trim(strNextLine2)
        'wscript.echo "test array : " & array2
       array1 = trim(array2)
        loop

'This section is used to compare the two txt files and remove whatever variables that are in both txt files and deleting them.
array2.files
array2.files
   For Each textstream1 In array1
        found = False
    For Each textstream2 In array2
      If textstream1 = textstream2 Then
        found = True
        Exit For
    End If
        found = False
    Next
      If found = False Then
        wscript.echo "This isn't on approve shares text : " &textstream2
     End If 
    Next

'Another section for logging the process, logging the lines that were deleted

1 个答案:

答案 0 :(得分:3)

不是答案:

给定一个包含以下行的文件X:

A
B
C

包含以下内容的文件Y

A
B
C
1
2
3

以及“从第二个文件中删除不在第一个文件中的行”的任务,以便Y看起来像:

A
B
C

显而易见的解决方案是将X复制到Y上 - 不是代码,没有编码暴行,没有错误信息。

那么你的情况有什么不同?