I am attempting to format certain text in a Richtextbox by using Tags. My problem is that when I attempt to remove the tags using the Replace Function I lose all of the prior formatting. Here is my code:

VB Code:
  1. Option Explicit
  2.  
  3. Private Sub Command1_Click()
  4.     Call TextBold(RichTextBox1)
  5.     Call TextColor(RichTextBox1, vbRed)
  6.     Call TextCenter(RichTextBox1)
  7.     Call TextRight(RichTextBox1)
  8.     Call TextItalics(RichTextBox1)
  9. End Sub
  10.  
  11. Private Sub Command2_Click()
  12.     'When I click on the button I lose all formatting
  13.     With RichTextBox1
  14.         .Refresh
  15.         .Text = Replace(.Text, "<", "")
  16.         .Text = Replace(.Text, ">", "")
  17.         .Text = Replace(.Text, "(", "")
  18.         .Text = Replace(.Text, ")", "")
  19.         .Text = Replace(.Text, "{", "")
  20.         .Text = Replace(.Text, "}", "")
  21.         .Refresh
  22.     End With
  23. End Sub
  24.  
  25. Private Sub Form_Load()
  26.     With RichTextBox1
  27.         .Text = "<1>" & vbNewLine 'Color these Characters Blue
  28.         .Text = .Text & "<(5-6-58)>" & vbNewLine 'Bold These Characters & Center Align
  29.         .Text = .Text & "{$1-23-88%}" & vbNewLine 'Italicizes These Characters & Right Align
  30.     End With
  31. End Sub
  32.  
  33. Private Sub TextBold(RTB As RichTextBox)
  34. Dim lngTag_Start As Long
  35. Dim lngTag_End As Integer
  36. Dim strText As String
  37.  
  38. lngTag_End = 1
  39.  
  40. With RTB
  41.     strText = .Text
  42.    
  43.     Do While InStr(lngTag_End, strText, "<") > 0
  44.         .SelLength = 0
  45.         lngTag_Start = InStr(lngTag_End, strText, "<")
  46.         lngTag_End = InStr(lngTag_Start, strText, ">")
  47.         .SelStart = lngTag_Start
  48.         .SelLength = (lngTag_End - lngTag_Start) - 1
  49.         .SelBold = True
  50.         lngTag_End = lngTag_End + 1
  51.     Loop
  52. End With
  53.  
  54. End Sub
  55.  
  56. Private Sub TextCenter(RTB As RichTextBox)
  57. Dim lngTag_Start As Long
  58. Dim lngTag_End As Integer
  59. Dim strText As String
  60.  
  61. lngTag_End = 1
  62.  
  63. With RTB
  64.     strText = .Text
  65.    
  66.     Do While InStr(lngTag_End, strText, "(") > 0
  67.         .SelLength = 0
  68.         lngTag_Start = InStr(lngTag_End, strText, "(")
  69.         lngTag_End = InStr(lngTag_Start, strText, ")")
  70.         .SelStart = lngTag_Start
  71.         .SelLength = (lngTag_End - lngTag_Start) - 1
  72.         .SelAlignment = rtfCenter
  73.         lngTag_End = lngTag_End + 1
  74.     Loop
  75. End With
  76.  
  77. End Sub
  78.  
  79. Private Sub TextColor(RTB As RichTextBox, lngColor As Long)
  80. Dim lngTag_Start As Long
  81. Dim lngTag_End As Integer
  82. Dim strText As String
  83.  
  84. lngTag_End = 1
  85.  
  86. With RTB
  87.     strText = .Text
  88.    
  89.     Do While InStr(lngTag_End, strText, "<") > 0
  90.         .SelLength = 0
  91.         lngTag_Start = InStr(lngTag_End, strText, "<")
  92.         lngTag_End = InStr(lngTag_Start, strText, ">")
  93.         .SelStart = lngTag_Start
  94.         .SelLength = (lngTag_End - lngTag_Start) - 1
  95.         .SelColor = lngColor
  96.         lngTag_End = lngTag_End + 1
  97.     Loop
  98. End With
  99.  
  100. End Sub
  101.  
  102. Private Sub TextRight(RTB As RichTextBox)
  103. Dim lngTag_Start As Long
  104. Dim lngTag_End As Integer
  105. Dim strText As String
  106.  
  107. lngTag_End = 1
  108.  
  109. With RTB
  110.     strText = .Text
  111.    
  112.     Do While InStr(lngTag_End, strText, "$") > 0
  113.         .SelLength = 0
  114.         lngTag_Start = InStr(lngTag_End, strText, "$")
  115.         lngTag_End = InStr(lngTag_Start, strText, "%")
  116.         .SelStart = lngTag_Start
  117.         .SelLength = (lngTag_End - lngTag_Start) - 1
  118.         .SelAlignment = rtfRight
  119.         lngTag_End = lngTag_End + 1
  120.     Loop
  121. End With
  122.  
  123. End Sub
  124.  
  125. Private Sub TextItalics(RTB As RichTextBox)
  126. Dim lngTag_Start As Long
  127. Dim lngTag_End As Integer
  128. Dim strText As String
  129.  
  130. lngTag_End = 1
  131.  
  132. With RTB
  133.     strText = .Text
  134.    
  135.     Do While InStr(lngTag_End, strText, "{") > 0
  136.         .SelLength = 0
  137.         lngTag_Start = InStr(lngTag_End, strText, "{")
  138.         lngTag_End = InStr(lngTag_Start, strText, "}")
  139.         .SelStart = lngTag_Start
  140.         .SelLength = (lngTag_End - lngTag_Start) - 1
  141.         .SelItalic = True
  142.         lngTag_End = lngTag_End + 1
  143.     Loop
  144. End With
  145.  
  146. End Sub