I've created a function to output richtext. I'm just wondering if there's a better way. The programs that call this will usually not be windows forms.

VB Code:
  1. Public Sub WriteText(ByVal Data As String, ByVal outputPath As String)
  2.         Dim rtf As New RichTextBox
  3.         Dim StartBold As Boolean = False
  4.         Dim boldFont As New System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 12, FontStyle.Bold)
  5.         Dim normalFont As New System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 12, FontStyle.Regular)
  6.         Dim dataArray() As String = Regex.Split(Data, "(<b>|</b>)")
  7.         For Each s As String In dataArray
  8.             If s = "<b>" Then
  9.                 StartBold = True
  10.                 s = ""
  11.             ElseIf s = "</b>" Then
  12.                 StartBold = False
  13.                 s = ""
  14.             End If
  15.  
  16.             If StartBold Then
  17.                 rtf.AppendText(s)
  18.                 rtf.Select(rtf.Text.Length - s.Length, s.Length)
  19.                 rtf.SelectionFont = boldFont
  20.             Else
  21.                 rtf.AppendText(s)
  22.                 rtf.Select(rtf.Text.Length - s.Length, s.Length)
  23.                 rtf.SelectionFont = normalFont
  24.             End If
  25.  
  26.         Next
  27.         rtf.SaveFile(outputPath)
  28.     End Sub