right I'm pasting the VB here for the parse code. It's pretty simple in terms of structures and no doubt could be shortened. NOTE: This is for VB6, not .NET.
Code:
Public Sub Parse(Data As RichTextBox)
Dim Length As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim o As Integer
Length = Len(Data.Text)
For i = 1 To Length
If Length - i >= 1 Then
If Mid(Data.Text, i, 2) = "\n" Then
If Mid(Data.Text, i + 3, 4) = "font" Then
'do nout
ElseIf Mid(Data.Text, i + 3, 3) = "dc=" Then
'This bit doesn't work. I don't know why. It's supposed to set the color of the text.
Data.SelStart = i
For j = 0 To 3
If Mid(Data.Text, i + 6 + j, 1) = "," Then
Exit For
End If
Next j
For k = 0 To 3
If Mid(Data.Text, i + 6 + j + k + 1, 1) = "," Then
Exit For
End If
Next k
For l = 0 To 3
Debug.Print Mid(Data.Text, i + 6 + j + k + 2 + l, 1)
If Mid(Data.Text, i + 6 + j + k + 2 + l, 1) = ">" Then
Exit For
End If
Next l
Data.SelLength = Length - i
Data.SelColor = RGB(Mid(Data.Text, i + 6, j), Mid(Data.Text, i + 7 + j, k), Mid(Data.Text, i + 8 + j + k, l))
For o = i + 3 To i + 32
If Mid(Data.Text, o, 2) = "\n" Then
o = o + 2
Exit For
End If
Next o
Data.Text = Mid(Data.Text, 1, i - 1) & "(R:" & Mid(Data.Text, i + 6, j) & ",G:" & Mid(Data.Text, i + 7 + j, k) & ",B:" & Mid(Data.Text, i + 8 + j + k, l) & ") " & Mid(Data.Text, o)
Data.SelStart = i
'End of b0rked bit
'Check for left justify markers
ElseIf Mid(Data.Text, i + 3, 2) = "jl" Then
Data.Text = Mid(Data.Text, 1, i - 1) & Mid(Data.Text, i + 8)
Data.SelStart = i
Data.SelLength = Length - i
Data.SelAlignment = 0
'Check for right justify markers
ElseIf Mid(Data.Text, i + 3, 2) = "jr" Then
Data.Text = Mid(Data.Text, 1, i - 1) & Mid(Data.Text, i + 8)
Data.SelStart = i
Data.SelLength = Length - i
Data.SelAlignment = 1
'Check for center justify markers
ElseIf Mid(Data.Text, i + 3, 2) = "jc" Then
Data.Text = Mid(Data.Text, 1, i - 1) & Mid(Data.Text, i + 8)
Data.SelStart = i
Data.SelLength = Length - i
Data.SelAlignment = 2
'Check for line breaks
ElseIf Mid(Data.Text, i + 3, 2) = "br" Then
Data.Text = Mid(Data.Text, 1, i - 1) & Chr(13) & Mid(Data.Text, i + 8)
Data.SelStart = i
'Check for paragraph breaks
ElseIf Mid(Data.Text, i + 3, 2) = "p>" Then
Data.Text = Mid(Data.Text, 1, i - 1) & Chr(13) & Chr(13) & Mid(Data.Text, i + 7)
Data.SelStart = i
'Check for page breaks
ElseIf Mid(Data.Text, i + 3, 2) = "pb" Then
Data.Text = Mid(Data.Text, 1, i - 1) & Chr(13) & "-----------------Page Break------------" & Chr(13) & Mid(Data.Text, i + 8)
Data.SelStart = i
End If
End If
End If
Next i
Basically what happens is that the code for justifying works, except when I put another justification in at a differentpoint, after a break, the whole rich text box justifies in that way.
Also the color doesn't change the font color.
If anyone has any knowledge of VB and can work this out, please tell me.