Click to See Complete Forum and Search --> : RichText


jan McC
June 15th, 2001, 05:52 PM
I would like to find the easiest way to highlight specific text where I have a subroutine passing a value to a richtextbox using Dim ctext as string and the code is somthing like this. I would really appreciate someone's help on this. I have a deadline that has come and gone. Thank-you

{vbcode]
Option Explicit
Private Const Problem_TEXT_HEADER = "<html><head<style>body { font-family: Arial; font-size: 12pt }</style><title></title></head><body bgcolor='#C1E5EB' topmargin='4' leftmargin='6'>"
' <style type = 'text/css'> B {background-color: #HFFFFF;}</style>

Private Const Problem_TEXT_FOOTER = "</body></html>"
Public Sub Test1SetStepProblemText(ByVal UserForm As Test, ByVal StepNumber As Long)
' sets the html text

Dim cText As String

Select Case StepNumber
Case 1
cText = "This is the text and I would like to highlight a few words in the middle of this sentence" _
& " continuing to use the this setup. There is a public constant declaration ."
End Sub
[/vbcode]

John G Duffy
June 15th, 2001, 06:40 PM
The sample below will do things to the selected String.
Put a Richtextbox on a form. Add a command button
Paste this code into the forms general declaration section.
Click the button and the word TEXT should come to life. How you determine the start and length of the text you wish to highlight I can't help you with.

private Sub Command1_Click()
RichTextBox1.SelStart = 4 ' the starting point of the text to highlight
RichTextBox1.SelLength = 4 ' the length of the text to highlight
RichTextBox1.SelColor = vbRed ' set its color to RED
RichTextBox1.SelBold = true
RichTextBox1.SelUnderline = true
End Sub




John G