Solved

rich textbox control vb looping to bold

Posted on 2006-06-23
4
280 Views
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?
0
Comment
Question by:jackjohnson44
[X]
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
4 Comments
 
LVL 9

Expert Comment

by:justchat_1
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
lastx=x
--all the code from above--
loop
0
 

Author Comment

by:jackjohnson44
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
                Else
                    breakWhile = True
                End If
            Wend
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16971152
RichTextBox1.TextRTF = Replace(RichTextBox1.TextRTF, "<b>", "")
RichTextBox1.TextRTF = Replace(RichTextBox1.TextRTF, "</b>", "")
0
 
LVL 9

Accepted Solution

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

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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
Course of the Month4 days, 9 hours left to enroll

636 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