热心网友
回答时间:2024-04-15 03:06
你需要先弄一个文本框
把T1.TXT和T2.TXT的内容读进去
用一个按钮事件 读取文件T1.TXT和T2.TXT
Dim OpenFileDialog As New OpenFileDialog
Dim f As System.IO.FileStream
Dim r As System.IO.StreamReader
OpenFileDialog.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
If (OpenFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = OpenFileDialog.FileName
f = New System.IO.FileStream(FileName, IO.FileMode.Open, IO.FileAccess.Read)
r = New System.IO.StreamReader(f)
TextBox1.Text += r.ReadToEnd
r.Close()
End If
另一个按钮保存 TextBox1.Text
Dim w As System.IO.StreamWriter
Dim f As System.IO.FileStream
Dim FileName As String
If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
SaveFileDialog.FileName=T3.TXT
FileName = SaveFileDialog.FileName
f = New System.IO.FileStream(FileName, IO.FileMode.Create, IO.FileAccess.Write)
w = New System.IO.StreamWriter(f)
w.Write(textbox.Text)
w.Close()
End If
收起