Click here to Skip to main content
15,884,472 members
Articles / Web Development / HTML
Article

Using a VB.NET 2005 Class to Convert RichText to HTML

Rate me:
Please Sign up or sign in to vote.
4.55/5 (31 votes)
2 Nov 2006CPOL 214K   10.2K   78   61
A quick way to convert RichText to HTML.

A window showing a Rich Editor and the resutling HTML code

Introduction

This code was written to solve the problem of having RichText data needing to be displayed in HTML, both in HTML reports and in ASP.NET web pages.

Using the code

Use of the code is exceptionally simple. Simply create a new instance of the class and then use the properties to first pass in the RichText to parse and then use the html property to get the resulting HTML. (The code file for the class is attached to this article).

VB
''Assume you have a RichTextBox on your 
''form named rtbFoo and a button named btnBar

  Private Sub btnBar_Click(ByVal sender as object, _
          e as System.EventArgs) Handles btnBar.Click
    dim r2h as new RTFtoHTML
    r2h.rtf = rtbFoo.rtf
    messagebox.show(r2h.html)
  End Sub

History

  • Initial release - 11/02/2006.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United States United States
Developing software since 1995, starting out with Borland Turbo C++ 3 & Motorolla Assembly.
Eventually learning several different languages such as
Pascal/Delphi,Basic, Visual Basic,FoxPro, ASP, PHP, and Perl.

Currently using the .net framework for most development task.

Hobbies include underwater robotics, and electronics.

George's current language of choice is C#.

Comments and Discussions

 
QuestionCombined with RTBExVB Pin
bigbro_19858-Aug-10 20:29
professionalbigbro_19858-Aug-10 20:29 
AnswerRe: Combined with RTBExVB Pin
George H. Slaterpryce III3-Sep-10 9:57
George H. Slaterpryce III3-Sep-10 9:57 
AnswerRe: Combined with RTBExVB Pin
ajdjnfdfd21-Dec-14 2:57
ajdjnfdfd21-Dec-14 2:57 
GeneralCode for changing the Font and the FontSize with ListBox Pin
vb_newsbie12-Jul-10 21:14
vb_newsbie12-Jul-10 21:14 
GeneralRe: Code for changing the Font and the FontSize with ListBox Pin
vb_newsbie14-Jul-10 0:16
vb_newsbie14-Jul-10 0:16 
GeneralHi George Slaterpryce III Pin
Curtis Underwood17-May-10 6:38
Curtis Underwood17-May-10 6:38 
GeneralRe: Hi George Slaterpryce III Pin
George H. Slaterpryce III3-Sep-10 9:58
George H. Slaterpryce III3-Sep-10 9:58 
GeneralNice Article Pin
jayeshshah8-Dec-09 16:55
jayeshshah8-Dec-09 16:55 
Hi, this is a really nice and helpful article.
Is there any specific code to convert from HTML to richtext ? I currently have a richtextbox where i need to show the html content from a HTML-page.
GeneralBugs Pin
hristo14220-Apr-09 21:55
hristo14220-Apr-09 21:55 
GeneralRe: Bugs Pin
Sorwen30-Apr-09 6:59
Sorwen30-Apr-09 6:59 
GeneralRe: Bugs Pin
joseph_man6-May-09 4:02
joseph_man6-May-09 4:02 
GeneralRe: Bugs Pin
Sorwen5-Jun-09 17:03
Sorwen5-Jun-09 17:03 
GeneralRe: Bugs Pin
DjBepy15-Jul-09 2:22
DjBepy15-Jul-09 2:22 
GeneralRe: Bugs Pin
wouterdebo3-Feb-10 22:10
wouterdebo3-Feb-10 22:10 
GeneralRe: Bugs Pin
Sorwen4-Feb-10 11:30
Sorwen4-Feb-10 11:30 
AnswerRe: Bugs Pin
amitk86-Dec-10 10:42
amitk86-Dec-10 10:42 
Generalhi Pin
mwau25-Feb-09 23:01
mwau25-Feb-09 23:01 
GeneralNot saving any image Pin
suis11-Feb-09 6:40
suis11-Feb-09 6:40 
GeneralHey.. good one .. Pin
Abhishek Sur27-Aug-08 22:00
professionalAbhishek Sur27-Aug-08 22:00 
Generalsaving the converted file Pin
quioske9-May-08 3:57
quioske9-May-08 3:57 
GeneralNice Pin
karenpayne6-Aug-07 3:09
karenpayne6-Aug-07 3:09 
Generalescape characters Pin
gary73-Aug-07 10:52
gary73-Aug-07 10:52 
GeneralUnderline Pin
frederic.robert29-May-07 5:02
frederic.robert29-May-07 5:02 
GeneralRe: Underline Pin
George H. Slaterpryce III18-Jul-07 13:29
George H. Slaterpryce III18-Jul-07 13:29 
GeneralRe: Underline Pin
Member 1392768115-Aug-19 23:33
Member 1392768115-Aug-19 23:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.