william007
asked on
Richtextbox problem about Appending text
Hi, the resulting text supposed to be
<b>Highlighted</b> No Highlighted
(<b>..</b> is the portion that bold)
But the result appeared to be all bold, How to solve it?
Followed is the code: (rtf is the name of richtextbox)
Private Sub Command1_Click()
Dim index As Integer
Dim iStart As Integer
Me.rtf.Text = ""
Dim iLength As Integer
iStart = Len(rtf.Text)
rtfAppend rtf, "Highlighted "
iLength = Len(rtf.Text) - iStart
rtf.SelStart = iStart
rtf.SelLength = iLength
rtf.SelBold = True
rtfAppend rtf, " No Highlight"
End Sub
Private Sub rtfAppend(ByVal rtf As RichTextBox, ByVal str As String)
rtf.SelStart = Len(rtf.Text)
rtf.SelLength = 0
rtf.SelText = str
'rtfComponent.SelBold = False
End Sub
<b>Highlighted</b> No Highlighted
(<b>..</b> is the portion that bold)
But the result appeared to be all bold, How to solve it?
Followed is the code: (rtf is the name of richtextbox)
Private Sub Command1_Click()
Dim index As Integer
Dim iStart As Integer
Me.rtf.Text = ""
Dim iLength As Integer
iStart = Len(rtf.Text)
rtfAppend rtf, "Highlighted "
iLength = Len(rtf.Text) - iStart
rtf.SelStart = iStart
rtf.SelLength = iLength
rtf.SelBold = True
rtfAppend rtf, " No Highlight"
End Sub
Private Sub rtfAppend(ByVal rtf As RichTextBox, ByVal str As String)
rtf.SelStart = Len(rtf.Text)
rtf.SelLength = 0
rtf.SelText = str
'rtfComponent.SelBold = False
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The AppendText function will be really useful in the future=) Thanks again for the excellent solution!
ASKER