change.vb
来自「用于richtext框中」· VB 代码 · 共 21 行
VB
21 行
Imports System.IO
Public Class Change
Dim mytext As String
Public Sub mychange(ByVal path As String, ByVal oldstring As String, ByVal newstring As String)
'path为要修改的文件路径 oldstring为要修改的字符串 newstring为修改后的字符串
Try
'读取文件
Using myStreamReader As StreamReader = File.OpenText(path)
mytext = myStreamReader.ReadToEnd()
End Using
'更改
mytext = mytext.Replace(oldstring, newstring)
'写回
My.Computer.FileSystem.WriteAllText(path, mytext, False)
Catch ex As Exception
MsgBox("文件操作出错")
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?