
Indenting Text With RichTextBox
I need to indent text using a RichTextBox but am having all kinds of
problems doing so. My procedure loops thru my MS-Access database from record
to record placing text onto a RichTextBox. This is a typical multiple-choice
test I am creating. I want the answer choices to be indented. I have not
found a good way to accomplish this in an automated fashion. Here is the
pertinent code I am using:
' This line places just the text of a memo field into a hidden RichTextBox
(strips RTF)
rtfHidden.Text = "": rtfHidden.SelRTF = rst.Fields("stuChoiceA").Value
' This line displays a student answer choice memo field data onto my main
RichTextBox
Text1.SelText = "(A). ": Text1.SelRTF = rst.Fields("stuChoiceA").Value
' This line finds the exact same string as the previous line, highlights
the found match and indents
' The highlighted text
Text1.Find "(A). " & rtfHidden.Text: Text1.SelIndent = 1000
' This line deselects any text that may be selected
Text1.SelText=""
What occurs by this code is that my entire answer choice 'A' is deleted from
my main RichTextBox. I believe because the found text is highlighted and
because it is in a loop, it is eventually deleted the next time Text1.SelRTF
places data on the RichTextBox. I've tried many variations of this code with
no luck.
This code will work if I place it inside a command button and select it
after all the data has reached the RichTextBox. However, I want to have
indenting done automatically.
I may be out to lunch on the technique I am using, I am going off the help
info that came with VB.
Any ideas how I may be able to indent text while it is printing to a
RichTextBox inside a loop?
Tim Hirtle