✔ 最佳答案
Dim sBuffer As String, Keyword As String
Dim KeywordLen As Integer, Position As Integer
Open myfile For Input As #1
sBuffer = (Input$(LOF(1), 1)) ' 一次過將 file 讀進 sBuffer
Close #1
KeywordLen = Len(Keyword) ' 關鍵字長度
Position = 1
Do Until ( Position < 1 Or Len(sBuffer) = 0 )
Position = InStr(1, sBuffer, Keyword, vbTextCompare) ' 找出關鍵字
If Position > 0 Then ' 找到關鍵字
' 印出關鍵字後面相同數量的字
Debug.Print Mid(sBuffer, Position + KeywordLen, KeywordLen)
' 將 sBuffer 之前部分刪除
sBuffer = Mid(sBuffer, Position + KeywordLen)
End If
Loop ' 重復直到找不到關鍵字或 sBuffer 已經完全刪除