作者ldluliu (Liu-Liu)
看板Visual_Basic
标题Re: [.NET] 如何将文字内容存为一个txt档呢?
时间Wed Sep 2 11:03:19 2009
这是用 Visual Studio 2008 写出来的
Imports System
Imports System.IO
Public Class Form1
Dim myfilename As String = "D:\文字档.txt"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sw As New StreamWriter(myfilename)
sw.Write(TextBox1.Text) '将 TextBox 文字资料写入档案中
sw.Close() '关闭档案
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If File.Exists(myfilename) = True Then '判断档案是否存在,如果档案存在,则读取该档案
Dim sw As New StreamReader(myfilename)
TextBox1.Text = sw.ReadToEnd '将档案的文字资料读入 TextBox 内
sw.Close() '关闭档案
End If
End Sub
End Class
※ 引述《JYLai (是男人也可以是个男孩~)》之铭言:
: 小弟我是个新手~~
: 我想写个小程式~就是把textbox.text的内容存在d槽为一个文字档.txt
: 我不知指令是什麽 还有要如何宣告~
: 是否有人能写出程式码给我参考呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.124.3.111