いくつかのバリエーションをリストする必要があります。最初のリストのサンプル
リスト1)
hkdhksa
OP-ID: 111112
jklfjdlkfsd
hfldhfjksdf
OP-ID: 111113
ghjg
OP-ID: 111114
OP-ID: 111115
gjgjhghgjhg
OP-ID: 111116
OP-ID: 111117
OP-ID: 111118
リスト 2)
OP-ID: 111112
OP-ID: 11113
OP-ID: 111114
OP-ID: 111115
OP-ID: 111117
結果は次のようになります: OP-ID: 11118 is not in List 2
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'Declare two dictionaries. The key for each will be
' the text from the input line up to,
'but not including the first ",".
' The valus for each will be the entire input line.
'Dim file1 As New HashSet(Of String) '!
Dim file1 As New Dictionary(Of String, String)
Dim file2 As New Dictionary(Of String, String)
For Each line As String In System.IO.File.ReadAllLines(TEST1)
Dim part() As String = line.Split(",")
If line = ("OP-ID: ") Like "OP-ID:*" Then
If Not file1.ContainsKey(part(0)) Then file1.Add(part(0), line)
End If
Next
For Each line As String In System.IO.File.ReadAllLines(TEST2)
Dim part() As String = line.Split(",")
If Not file2.ContainsKey(part(0)) Then file2.Add(part(0), line) '!
Next
Dim keysInList1ThatAreNotInList2 = file1.Keys.Except(file2.Keys)
Dim values = From key In keysInList1ThatAreNotInList2 Select file1(key)
Dim str = String.Join(vbCrLf, values)
txtResults.Text = ("IDs should not be in list: " & str)
End Sub