Button replacing textarea information

I have the below code in a button to insert “Heading 1” in TextArea
When Heading 2 button is pressed it replaces Heading 1 textarea information. Can any of you lovely people tell me how to stop the replacement from happening?

What I want is when Buttons are pressed, information is printed to the textarea and not replaced.

Var txt As String // text to be displayed in TextArea
Var st, ln As Integer // start and length values of a paragraph
// define four paragraphs in Text
txt = "Heading 1 "+ EndOfLine _

EditingField.StyledText.Text = txt // four paragraphs in Text
EditingField.StyledText.Bold(5, 2) = True
EditingField.StyledText.Size(7, 10) = 12
EditingField.StyledText.Font(0, txt.Length) = “Times New Roman”
EditingField.StyledText.ParagraphTextAlignment(1) = TextAlignments.Center
EditingField.LineSpacing = 2

You’ll want to use the TextArea.AddText() method to append text. The line

EditingField.StyledText.Text = txt

replaces the entire content of the field. You’ll want the style statements before you call AddText() to set the style for the text to be added, though it also looks like you are setting style runs within the added text, so you’ll either have to figure out the correct start points and apply them after you AddText() or add the text in segments for each style run.

Thank you, I’ll try

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.