Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Public Sub RichTextBox_LoadFileHtml(RTB As RichTextBox, aFileName As String) Dim fis As New FileInputStream(aFileName) Dim doc As New HTMLDocument Dim kit As New HTMLEditorKit doc.putProperty "IgnoreCharsetDirective", New Boolean(True) RTB.Parent.setEditorKit kit RTB.Parent.setDocument doc kit.read fis, doc, 0 fis.close End Sub Public Sub RichTextBox_SaveFileHtml(RTB As RichTextBox, aFileName As String) Dim fos As New FileOutputStream(New File(aFileName)) Dim doc As Document = RTB.Parent.getDocument Dim kit As HTMLEditorKit = Cast(RTB.Parent.getEditorKit, HTMLEditorKit) kit.Write fos, doc, 0,0 fos.close End Sub |
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Public Sub SaveHTML Dim AftSave As String With CommonDialog1 .ShowSave If CommonDialog1.FileName="" Then Exit Sub 'Head AftSave="<html>"+chr(10)+"<head>"+chr(10)+"<title>Title</title>"+chr(10)+"</head>" 'Body AftSave=AftSave+chr(10)+"<body><p>"+RichTextBox1.Text+"</p></body></html>" SaveText2(AftSave,CommonDialog1.FileName) End With End Sub Public Sub SaveText2(Text As String, FileName As String) Dim File1 As VBFileHandler File1=Open(FileName) Write(File1,Text) End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Public Sub RichTextBox_SaveFileHTM(RTB As RichTextBox, aFileName As String) RichTextBox_SaveFile(RTB, aFileName, "text/html") End Sub Public Sub RichTextBox_SaveFile(RTB As RichTextBox, aFileName As String) 'default because RichText = rtf RichTextBox_SaveFile(RTB, aFileName, "text/rtf") End Sub Public Sub RichTextBox_SaveFile(RTB As RichTextBox, aFileName As String, contenttype As String) 'contenttype could either be ' "text/plain", or ' "text/html", or ' "text/rtf" Dim os As OutputStream = New FileOutputStream(aFileName) Dim pan As JTextPane = RTB.Parent Dim kit As EditorKit = pan.getEditorKitForContentType(contenttype) Dim doc As Document = pan.getDocument Dim wri As Writer = New OutputStreamWriter(os) kit.write(os, doc, 0, doc.getLength) os.flush os.close End Sub |