重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
按你说的方式,需要用到钩子
创新互联专注于黟县网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供黟县营销型网站建设,黟县网站制作、黟县网页设计、黟县网站官网定制、成都微信小程序服务,打造黟县网络公司原创品牌,更为您提供黟县网站排名全网营销落地服务。
建议你用File类进行操作,保存为TXT文件
祝好运,望采纳
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
设计一个窗口,添加一个名为textBox1的System.Windows.Forms.TextBox,
添加一个名为button1的System.Windows.Forms.Button。
为button1的单击事件添加如下处理函数:
Sub Button1Click(sender As Object, e As EventArgs)
'f是你的文本文件的文件名
Const f As String="t.txt"
Dim sw As System.IO.StreamWriter=Nothing
Try
If Not System.IO.File.Exists(f) Then
sw=System.IO.File.CreateText(f)
Else
sw=New System.IO.StreamWriter(f,True)
End If
sw.WriteLine(textBox1.Text)
Finally
If sw IsNot Nothing Then
sw.close()
End If
End Try
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
窗体上添加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
气斜射入水或其他介质,折射光线与入射光线法线在