If you want to load literal code, rather than a file, into a WebBrowser then you set its DocumentText property. To get the text from a RichTextBox you get its Text property. Put the two together and you have your solution.