2013-10-17 103 views
0

我試圖創建兩個文件的數組,並比較兩個,但我打了一堵牆。我不斷收到錯誤「object required'added4'」,我也需要讀取兩個文件將它們放入一個數組中,比較兩個文件並從第二個文件中刪除不在第一個文件中的行。 我也想記錄我刪除的行。我不斷收到錯誤「object required」added4'「

'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

輸入: 測試 一個 teset1 的Flexera 的FLEXnet 型 文件類型 ACT 法數據庫 acttest –

+0

輸出將是第一個txt文件,但第二個同樣的情況也有一對夫婦刪除線不在第一個 –

回答

3

不是一個答案:

鑑於包含行的文件X:含

A 
B 
C 

文件Y:

A 
B 
C 
1 
2 
3 

和「刪除該任務第二個文件中不在第一行的行「,因此Y看起來像:

A 
B 
C 

顯而易見的解決方案是一種通過Y複製X - 沒有編碼,沒有編碼的暴行,沒有錯誤消息。

那麼你的情況有什麼不同?