十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
站在用户的角度思考问题,与客户深入沟通,找到霍山网站设计与霍山网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站建设、做网站、企业官网、英文网站、手机端网站、网站推广、域名注册、网页空间、企业邮箱。业务覆盖霍山地区。
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, "1111", True)
End If
就可以了
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim aa As System.IO.StreamWriter = New System.IO.StreamWriter("C:\a.txt", False, System.Text.Encoding.UTF8)
Dim i As Integer = 0
For i = 0 To Val(TextBox4.Text)
aa.WriteLine("[" i "]")
aa.WriteLine("[" i "]")
Next
aa.Close()
aa.Dispose()
End Sub
写入:Dim sr As New IO.StreamWriter(Application.StartupPath "/写入的文本.txt")
sr.WriteLine("写入的内容") sr.Close()读取:If (File.Exists(Application.StartupPath "/msg.txt")) Then
Dim fm As New IO.FileStream(Application.StartupPath "/读取的文本.txt", FileMode.Open)
Dim sr As IO.StreamReader = New IO.StreamReader(fm)
Do While sr.Peek() = 0
TextBox1.Text = sr.ReadLine() (读取文本到文本框)
Loop end if
按你说的方式,需要用到钩子
建议你用File类进行操作,保存为TXT文件
祝好运,望采纳
如果想继续编辑之前的文档,在TXT文件尾部继续添加文本,那么还需要在函数后边加个参数。
VB 代码
方法1:
Dim sw As StreamWriter = New StreamWriter("C:\temp\test.txt")
sw.Write("abc" vbCrLf)
sw.Close()
Dim sw2 As StreamWriter = New StreamWriter("C:\temp\test.txt", True)
sw2.Write("456" vbCrLf)
sw2.Close()
方法2:
My.Computer.FileSystem.WriteAllText("test.txt", "This is test Text", True)
方法3:
System.IO.File.AppendAllText("c:\temp\test.txt", "this is extra test file")
详见:“网页链接”
窗体上添加2个文本框,设置成多行,2个按钮,在文本框1里随便输入若干文字,可以多行,单击按钮1,保存到文件。然后单击按钮2,把刚才写入的文件读到文本框2里。
代码如下:
'写文本文件
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'创建(写入)一个文本文件
Dim MyStream As New System.IO.FileStream(Application.StartupPath "\Ssk.txt", System.IO.FileMode.Create)
Dim MyWriter As New System.IO.StreamWriter(MyStream, System.Text.Encoding.Default)
MyWriter.WriteLine(TextBox1.Text)
MyWriter.Flush()
MyWriter.Close()
MyStream.Close()
End Sub
'读文本文件
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'读取一个文本文件
Dim MyReader As New System.IO.StreamReader(Application.StartupPath "\Ssk.txt", System.Text.Encoding.UTF8)
TextBox2.Text = MyReader.ReadToEnd()
MyReader.Close()
End Sub
气斜射入水或其他介质,折射光线与入射光线法线在