假定是 ListBox:
strMsg = ""
Open "text1.txt" for Input As #1
For i = 0 To List1.ListCount - 1
If EOF(1) Then
strMsg = "Difference:" & VBCrLf & "In text1.text:" & VBCrLf & "In ListBox: " & List1.List(i)
Else
Line Input #1, strText
If strText<> List1.List(i) Then strMsg = "Difference:" & VBCrLf & "In text1.text:" strText & VBCrLf & "In ListBox: " & List1.List(i)
End If
Next i
Do Until EOF(1)
Line Input #1, strText
strMsg = "Difference:" & VBCrLf & "In text1.text:" strText & VBCrLf & "In ListBox: "
Loop
If strMsg = "" Then
MsgBox "Same"
Else
MsgBox strMsg
End If