Home > Software engineering >  For A text per before 11 digits deleted B data that exist in the text, and generate new data file VB
For A text per before 11 digits deleted B data that exist in the text, and generate new data file VB

Time:10-18

, I have two text format is different, but the first column is the same, want to remove delete from the list of the original data set containing data (only by comparing each before 11 digits), the results generated new data file, and a great god help to write a VB statements,
According to the contrast before 11, not according to the separator,
Had better use VBA, don't VBs

CodePudding user response:

The text must be ANSI code
 Sub demo () 
Dim d As Object, temp As String
The Set d=CreateObject (" scripting. The dictionary ")
Open "C: \ Users \ delete set. TXT" For Input As # 1
The Line Input # 1, temp
Do Until EOF (1)
The Line Input # 1, temp
D (Left (temp, 11))=""
Loop
Close # 1
Open "C: \ Users \ source data. TXT" For Input As # 1
Open "C: \ Users \ results. TXT" For the Output As # 2
The Line Input # 1, temp
Print # 2, temp
Do Until EOF (1)
The Line Input # 1, temp
If Not d.e xists (Left (temp, 11)) Then
Print # 2, temp
End the If
Loop
Close # 1, # 2
End Sub
  •  Tags:  
  • VBA
  • Related