jackjohnson44
asked on
rich textbox control vb looping to bold
I would like to use html tags in a rich textbox control to bold text inside <b> </b> tags.
I would like to enter the text, then have some code that will go through and find any text between the tags and bold it.
mystring="<b>bold this</b> regular font <b>bold this too</b>regular font<b>bold this three</b>"
rtxtText1.Text = mystring
how would I do this?
I would like to enter the text, then have some code that will go through and find any text between the tags and bold it.
mystring="<b>bold this</b> regular font <b>bold this too</b>regular font<b>bold this three</b>"
rtxtText1.Text = mystring
how would I do this?
ASKER
I got my code to work so that the part that I want bold is bold.
After this happens, how do I get rid of the bold tags? <B> and <\B>?
While (positionCounter <= Len(currentStepType(CStr(i )).value)) And (breakWhile = False)
If InStr(positionCounter, currentStepType(CStr(i)).v alue, "<B>") > 0 Then
rtxtMatrixDescription.SelS tart = InStr(positionCounter, currentStepType(CStr(i)).v alue, "<B>")
rtxtMatrixDescription.SelL ength = InStr(rtxtMatrixDescriptio n.SelStart , currentStepType(CStr(i)).v alue, "</B>") - rtxtMatrixDescription.SelS tart
positionCounter = rtxtMatrixDescription.SelS tart + rtxtMatrixDescription.SelL ength
rtxtMatrixDescription.SelB old = True
Else
breakWhile = True
End If
Wend
After this happens, how do I get rid of the bold tags? <B> and <\B>?
While (positionCounter <= Len(currentStepType(CStr(i
If InStr(positionCounter, currentStepType(CStr(i)).v
rtxtMatrixDescription.SelS
rtxtMatrixDescription.SelL
positionCounter = rtxtMatrixDescription.SelS
rtxtMatrixDescription.SelB
Else
breakWhile = True
End If
Wend
RichTextBox1.TextRTF = Replace(RichTextBox1.TextR TF, "<b>", "")
RichTextBox1.TextRTF = Replace(RichTextBox1.TextR TF, "</b>", "")
RichTextBox1.TextRTF = Replace(RichTextBox1.TextR
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Then set selStart as the first value and selLength as the second value minus the first value.
Calling selBold should take care of the bold issue.
Finally a replace statment for "<b>" and "<\b>" should get rid of the tags
As far as the loop:
while x<>last x
lastx=x
--all the code from above--
loop