Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


rich textbox control vb looping to bold

Posted on 2006-06-23
Medium Priority
Last Modified: 2010-04-30
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?
Question by:jackjohnson44
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 16970457
Use the instr method to find the <b> tags and </b> tags.  
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
--all the code from above--

Author Comment

ID: 16970778
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)).value, "<B>") > 0 Then
                    rtxtMatrixDescription.SelStart = InStr(positionCounter, currentStepType(CStr(i)).value, "<B>")
                    rtxtMatrixDescription.SelLength = InStr(rtxtMatrixDescription.SelStart, currentStepType(CStr(i)).value, "</B>") - rtxtMatrixDescription.SelStart
                    positionCounter = rtxtMatrixDescription.SelStart + rtxtMatrixDescription.SelLength
                    rtxtMatrixDescription.SelBold = True
                    breakWhile = True
                End If

Expert Comment

ID: 16971152
RichTextBox1.TextRTF = Replace(RichTextBox1.TextRTF, "<b>", "")
RichTextBox1.TextRTF = Replace(RichTextBox1.TextRTF, "</b>", "")

Accepted Solution

justchat_1 earned 2000 total points
ID: 16971158
well in your case:
rtxtMatrixDescription.TextRTF = Replace(rtxtMatrixDescription.TextRTF, "<b>", "")
rtxtMatrixDescription.TextRTF = Replace(rtxtMatrixDescription.TextRTF, "</b>", "")

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question