我是一个小编码器,我需要帮助才能在word文件中保存2个RichTextBox数据
看看这张图片
http://i.stack.imgur.com/N6dfW.png
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
On Error Resume Next
RichTextBox3.LoadFile("C:\Windows\Help\enter.txt", RichTextBoxStreamType.PlainText)
RichTextBox1.LoadFile("C:\Windows\Help\out.txt", RichTextBoxStreamType.PlainText)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Try
Dim dlg As SaveFileDialog = New SaveFileDialog
dlg.Title = "save"
dlg.FileName = "log out " & DateString
dlg.Filter = "Word (*.doc)|*.doc"
If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
RichTextBox1.SaveFile(dlg.FileName, RichTextBoxStreamType.RichText)
End If
Catch ex As Exception : End Try
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim dlg As SaveFileDialog = New SaveFileDialog
dlg.Title = "save"
dlg.FileName = "log enter " & DateString
dlg.Filter = "Word (*.doc)|*.doc"
If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
RichTextBox3.SaveFile(dlg.FileName, RichTextBoxStreamType.RichText)
End If
Catch ex As Exception : End Try
End Sub
我无法在照片上按下按钮((由箭头指示))
如果您需要源代码:https://www.mediafire.com/?6du52ybx5d8vyts
我希望得到帮助:(
由于
答案 0 :(得分:0)
RichTextBoxStreamType.RichText
会导致文件以RTF格式保存,因此您可以使用.rtf扩展名对其进行命名,并且可以通过Word读取它。您也可以使用RichTextBoxStreamType.PlainText
以.txt扩展名保存它,并且可以通过Word读取它。没有一种自动方式将其保存为.docx或.doc文件。
您可以将两个富文本框组合在一起:
System.IO.File.WriteAllText(filename, RichTextBox1.rtf & vbcrlf & RichTextBox3.rtf)
System.IO.File.WriteAllText(filename, RichTextBox1.txt & vbcrlf & RichTextBox3.txt)