vb.net保存成TXT文件后再从RICHTEXTBOX里打开为什么是乱码?

保存代码如下Dimsavefile1AsNewSaveFileDialogsavefile1.DefaultExt="*.txt"savefile1.Filter="te... 保存代码如下
Dim savefile1 As New SaveFileDialog

savefile1.DefaultExt = "*.txt "
savefile1.Filter = "text Files|*.txt "

If (savefile1.ShowDialog() = System.Windows.Forms.DialogResult.OK) _
And (savefile1.FileName.Length) > 0 Then

Dim savemessage As New System.IO.StreamWriter(savefile1.FileName, True)
Try
savemessage.WriteLine(Label1.Text + ": ")
savemessage.WriteLine(TextBox1.Text)
savemessage.WriteLine()
savemessage.WriteLine(Label2.Text + ": ")
savemessage.WriteLine(TextBox2.Text)
savemessage.WriteLine(Label3.Text + ": ")
savemessage.WriteLine(TextBox3.Text)
Catch
Throw
Finally
savemessage.Close()
End Try
End If
打开代码如下:
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName <> "" Then

RichTextBox1.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText)

End If
请问是不是我保存和打开存在问题,如果是应该如何修改打开代码,请详细说明谢谢!!可加分!
展开
 我来答
zhaobuping
2011-05-16 · TA获得超过340个赞
知道小有建树答主
回答量:195
采纳率:0%
帮助的人:268万
展开全部
你保存跟读取的格式不一致:这样就可以
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName <> "" Then
RichTextBox1.Text = IO.File.ReadAllText(OpenFileDialog1.FileName)
End If
End Sub
匿名用户
2011-05-16
展开全部
Private Declare Function icePub_readFileToText Lib "icePubDll.dll" (ByVal strFilename As String,ByVal strText As String,ByVal maxLen As Integer) As Integer

Dim a2 As Integer
Dim strText As String

strText=Space(1024+1)

a2 = icePub_readFileToText("D:\test\a.txt",strText,1024)

MsgBox strText

Private Declare Function icePub_writeTextToFile Lib "icePubDll.dll" (ByVal strText As String ,ByVal strFilename As String ,ByVal traceFlag As Integer) As Integer

Dim a2 As Integer

a2 = icePub_writeTextToFile("喝开水!","D:\program files\test\b.txt",1)

Private Declare Function icePub_appendTextToFile Lib "icePubDll.dll" (ByVal strText As String,ByVal strFilename As String,ByVal traceFlag As Integer) As Integer

Dim a2 As Integer

a2 = icePub_appendTextToFile("上火了!","D:\program files\test\d.txt",1)
a2 = icePub_appendTextToFile("回家休息!","D:\program files\test\d.txt",1)

http://dl.icese.net/dev.php?f=icePubDll.rar 下载
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式