Set to Bold in a loop is used only once!

Code:


TA.SelStart = TA.SelLength
TA.SelBold = True
TA.AddText SQLite_RS.Field("tbl_Name").StringValue + ":" + EndOfLine
TA.SelBold = False
TA.AddText SQLite_RS.Field("sql").StringValue + EndOfLine + EndOfLine

You will notice… only the first TABLE name is in Bold…

Result:
image

The code report the contents of the sqlite_master TABLE.

You may also notice that IF NOT EXISTS is stripped (but was in my CREATE string).

Do you have a question?
You set it to Bold, add some text,
then set it not not Bold, then add some more text.

What did you want to happen?

Exactly that…


Loop
  <Title in Bold> + EndOfLine
  <A line of standard text> + EndOfLine + EndOfLine
End Loop

Your code is unreadable…
What is TA?
What is SelBold?

Exactly that…

OK: so it does exactly that.
Do you have a problem?

It’s so awkward getting the correct syntax with so many changes happening over the last few years.

You are not specifying SelLength so its anyone’s guess as to what text is being selected.

This is untested forum code, try:

TA.SelStart = Len(TA.Text) 'Put the selection start just before the text we add below/at the end of current text
TA.AddText SQLite_RS.Field("tbl_Name").StringValue + ":" + EndOfLine
TA.SelLen = Len(TA.Text) - TA.SelStart 'Select the text just added above
TA.SelBold = True 'bold the selection
TA.AddText SQLite_RS.Field("sql").StringValue + EndOfLine + EndOfLine

TextArea / SelectionBold

Yes, it set to bold only on the first loop run; there are 4 “runs” in the loop, so in the last 3, the Title is drawn as Standard, not Bold.

I added the text after setting Bold; so no Length is needed (IMHO).
That is why I set the start position (TA.SelStart = TA.SelLength).

Edit:
Oh, yes, you select the text and set it to the Bold style…

I can be totally wrong in my head, but when I set Bold to the text insertion cursor, when I type text, it is drawn as Bold. (that is my logic that comes from Word Processors).

Yes, its not a toggle to affect the upcoming text, it simply changes the selection.

2 Likes