Dim read As New System.IO.StreamReader("C:\test.txt", System.Text.Encoding.GetEncoding("shift_jis")) Dim text As String = read.ReadToEnd() read.Close() If System.Text.RegularExpressions.Regex.IsMatch(text, ".*//.*") Then Const SearchWord As String = "//" Const SearchEndWord As String = vbCrLf Dim FoundIndex As Integer Dim FoundEnd As Integer Dim CutComment As String While 0 <= FoundIndex FoundIndex = text.IndexOf(SearchWord) FoundEnd = text.IndexOf(SearchEndWord) If FoundIndex > -1 Then If FoundEnd = -1 Then 'EOFの時 CutComment = text.Substring(FoundIndex) text = Replace(text, CutComment, String.Empty) Else CutComment = Mid(text, FoundIndex + 1, FoundEnd) text = Replace(text, CutComment, String.Empty) End If Else Exit While End If End While End If