Imports System.IO '程式開頭前需引用 Dim tmp, path as String path = "c:\xxx.txt" '定義路徑 tmp = File.ReadAllText(path) '讀取文字檔 InStr(tmp, "欲比對字串") '文字比對 tmp = tmp.Replace("原字串", "欲取代字串") '字串取代 File.WriteAllText(path, tmp) '寫入文字檔